Repository navigation
P0848R3 Conditionally Trivial Special Member Functions #474
gwllx
started this conversation in
Issue Triage - Standard Conformance
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The EDG implementation of C++20's conditionally trivial special member functions has a number of issues related in particular to ineligible user-provided overloads. The "eligible special member function" criteria is often not evaluated when deciding on triviality.
I noticed this while looking into an issue with
std::optionalin libstdc++, where e.g.std::optional<int>is not trivially copy/move-constructible or trivially copyable in EDG due to the use of constrained overloads in its base class: gcc/libstdc++-v3/include/std/optional#L546-554.A reproducer for this case is given in item 1 below. The others are related fallout from investigating this, and I think a fix would/should encompass them too.
1. An ineligible user-provided copy/move function makes derived and containing classes non-trivial
https://godbolt.org/z/7E1eqxeE6
src/class_decl.c#check_special_member_functions sets
makes_copy_construction_nontrivialwithout checking eligibility and this gets copied to the derived/containing class.2.
__is_trivially_copyablefails if an ineligible overload has an exception specificationhttps://godbolt.org/z/nj6MzedqY
3.
__is_trivially_copyablechecks only one nontrivial assignment operatorhttps://godbolt.org/z/W9WhffcM9
4. A user-provided non-const copy ctor makes derived copy ctors nontrivial
In this case EDG emulates the gcc behaviour (but I believe that is a bug: Bug 87051), even in clang and microsoft modes.
https://godbolt.org/z/9bYWaY178
All reactions