[cfe-dev] __is_trivially_copyable seems to be misbehaving
Howard Hinnant via cfe-dev
cfe-dev at lists.llvm.org
Fri May 27 12:23:08 PDT 2016
On May 27, 2016, at 3:17 PM, David Blaikie via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> 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?
http://stackoverflow.com/a/36164788/576911
Howard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160527/00353ed8/attachment.sig>
More information about the cfe-dev
mailing list