https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85270
Bug ID: 85270 Summary: Trivial assignment operator not considered such Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hstong at ca dot ibm.com Target Milestone: --- Trivial copy assignment operator not considered such GCC stops considering a trivial copy assignment operator to be trivial when a non-trivial copy assignment operator is added to the class. Works with Clang; fails with GCC. ### SOURCE (<stdin>): struct Q { Q &operator=(const Q &) = default; // defaulted on first declaration, not user-provided; trivial Q &operator=(Q &); // not a viable candidate at P1 }; static_assert(__is_trivially_assignable(Q &, const Q &), ""); // (P1) // Assertion succeeds with Clang and ICC, but fails with GCC. ### COMPILER INVOCATION: g++ -xc++ -std=c++2a -fsyntax-only - ### ACTUAL OUTPUT: <stdin>:8:15: error: static assertion failed ### EXPECTED OUTPUT: (Clean compile) ### COMPILER VERSION INFO (g++ -v): Using built-in specs. COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++ COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/8.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head --enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release --disable-nls --enable-lto LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32 Thread model: posix gcc version 8.0.1 20180405 (experimental) (GCC)