https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109180
Bug ID: 109180 Summary: Explicit template instantiation doesn't work for constexpr destructors on arm32 when optimizations are enabled Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: idhameed at protonmail dot com Target Milestone: --- Example (compile with "g++ -std=c++20 -O -c"): =========================================== template <typename t> struct record { constexpr ~record() { } }; inline record<char> return_record() { return {}; } template record<char>::~record(); =========================================== Compiler Explorer: https://godbolt.org/z/j37rvr961 GCC 10+ targeting 32-bit ARM won't emit any symbols for record<char>::~record when using most -O levels (-O, -O2, -O3, -Ofast, -Og). Using -fno-inline--or placing the explicit instantiation of record<char>::~record above the definition of return_record--works around this bug and causes a symbol for record<char>::~record to be emitted, as I'd expect. x86-64 GCC doesn't have this problem. The original, non-minimized problem I encountered: GCC 12.2.0 as a cross-compiler on an x86-64 host targeting arm-linux-gnueabihf can't be used to compile and link LLVM 15's libc++, because libc++'s implementation of std::basic_string has code that fits the aformentioned pattern--there's an overload of `std::__1::literals::string_literals::operator "" s` that returns a basic_string<char>. I tried the release/15.x branch of llvm-project at commit 92e7ef99303f8f367f279ccfa2393e4b96db915a.