https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112544

Boris Staletic <boris.staletic at protonmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |boris.staletic at protonmail 
dot c
                   |                            |om

--- Comment #2 from Boris Staletic <boris.staletic at protonmail dot com> ---
This bug is the root cause of a recently published cppnow lightning talk[1].
That got me curious and I had to get my hands dirty.

Here's an even smaller example:

template <typename T>
concept copyable = requires(T lhs) {
    { lhs = lhs };
};

using type = decltype([x = 2] {});
static_assert(__is_trivially_copyable(type), "");
constexpr bool discard = copyable<type>;
static_assert(__is_trivially_copyable(type), "");

That repros all the way back to gcc 5, before which "is trivially copyable" was
not a thing in gcc.

> Currently static_assert #1 succeeds and #2 fails seemingly because our 
> implementation of __is_trivially_copyable is sensitive to whether the 
> relevant special member functions have yet been synthesized.

Yes. In case of trivial copyability, specifically, gcc sets the
has_complex_copy_assign flag after synthesizing a deleted copy assignment.

However, according to [class.copy.assign]#9[2], deleted copy assignment is
still trivial and eligible.

I have not tried yet, but from where I stand, the solution could be to just not
set the non-trivial flags if the special member is deleted.

[1]: https://youtu.be/VEIJkIEKEQ4
[2]: https://eel.is/c++draft/class.copy.assign#9

Reply via email to