__is_trivially_copyable seems to be misbehaving

Example:

struct foo {
foo(foo &&) = default;
foo &operator=(foo &&) = default;
};

static_assert(__is_trivially_copyable(foo), “this really shouldn’t be true”);

This static-assert succeeds, yet the code:

void f(foo &x, foo &y) {
x = y;
}

fails.

This came up when someone on IRC tried to make a SmallVector of such things and LLVM’s isPodLike trait said “yes, this thing is podlike” and tried to use std::copy to copy them around (& that was just luck that it failed - in other places it used memcpy to copy them around, which would’ve been silent badness). isPodLike is implemented in terms of __is_trivially_copyable, where available. (granted, it’s implemented in terms of is_class where that’s not available - so we don’t have any code that /relies/ on the correctness of __is_trivially_copyable, only for optimization purposes)

Am I seeing that right?

  • Dave

http://stackoverflow.com/a/36164788/576911

Howard