public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109180] New: Explicit template instantiation doesn't work for constexpr destructors on arm32 when optimizations are enabled
@ 2023-03-17 23:02 idhameed at protonmail dot com
  0 siblings, 0 replies; only message in thread
From: idhameed at protonmail dot com @ 2023-03-17 23:02 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-17 23:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-17 23:02 [Bug c++/109180] New: Explicit template instantiation doesn't work for constexpr destructors on arm32 when optimizations are enabled idhameed at protonmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).