https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112318
Bug ID: 112318 Summary: Deprecated move ctor does not trigger -Wdeprecated-declarations when creating a std::optional Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: enolan at alumni dot cmu.edu Target Milestone: --- When constructing a std::optional value for a type whose move ctor is marked deprecated that invokes its move ctor, -Wdeprecated-declarations is not triggered. Compiler explorer link: https://godbolt.org/z/EPveeoEfn Minimal reproduction: #include <optional> struct foo { foo() {} [[deprecated]] foo(foo&&); }; void bar() { std::optional<foo> quux{foo{}}; } > the exact version of gcc g++ (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4) > the system type Fedora release 38 (Thirty Eight) > the options given when GCC was configured/built Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-13.2.1-20231011/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1 > the complete command line that triggers the bug g++ -c -Werror=deprecated-declarations poc.cpp > the compiler output