public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113063] New: Strange linker error in special case involving local class with defaulted spaceship operator and static assert
@ 2023-12-18 11:52 kristian.spangsege at gmail dot com
  2023-12-18 11:55 ` [Bug c++/113063] " kristian.spangsege at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: kristian.spangsege at gmail dot com @ 2023-12-18 11:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113063

            Bug ID: 113063
           Summary: Strange linker error in special case involving local
                    class with defaulted spaceship operator and static
                    assert
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kristian.spangsege at gmail dot com
  Target Milestone: ---

With the latest GCC (13.2) and also with GCC 11.4, the following C++ code
triggers a strange linker error:


#include <compare>

int main()
{
    struct X {
        auto operator<=>(const X&) const = default;
    };
    X x;
    static_assert(noexcept(x < x));
    static_cast<void>(x < x);
}


Godbolt: https://godbolt.org/z/PfPfznT6Y


The linker error is this:

/usr/bin/ld: /tmp/ccsnSU59.o: in function `main::X::operator<=>(X const&)
const':
t.cpp:(.text+0x31): undefined reference to
`std::strong_ordering::strong_ordering(std::strong_ordering const&)'


It seems to be a bug that is triggered by the presence of the static assertion,
but only when the it occurs before the actual invocation of the less-than
comparison operation. Also, if the local class (`X`) is moved out of `main()`,
the problem goes away.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-12-20 19:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-18 11:52 [Bug c++/113063] New: Strange linker error in special case involving local class with defaulted spaceship operator and static assert kristian.spangsege at gmail dot com
2023-12-18 11:55 ` [Bug c++/113063] " kristian.spangsege at gmail dot com
2023-12-18 16:49 ` pinskia at gcc dot gnu.org
2023-12-18 16:53 ` ppalka at gcc dot gnu.org
2023-12-19 21:34 ` cvs-commit at gcc dot gnu.org
2023-12-19 21:37 ` ppalka at gcc dot gnu.org
2023-12-20 19:20 ` kristian.spangsege at gmail 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).