public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115283] New: [14 Regression] "used but never defined" with extern templates
@ 2024-05-29 21:36 gcc at hazardy dot de
  2024-05-29 21:56 ` [Bug c++/115283] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gcc at hazardy dot de @ 2024-05-29 21:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115283
           Summary: [14 Regression] "used but never defined" with extern
                    templates
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at hazardy dot de
  Target Milestone: ---

This reduced code does work with GCC 13, but with 14 I get the "used but never
defined" warning (and later undefined refernces, even tho the symbols are
emitted to the object files).

See https://godbolt.org/z/Gsz4x7d6h

#include <concepts>
#include <type_traits>

template<typename T>
class C
{
public:
    using ResultT = std::conditional_t<std::same_as<T, void>, T, T>;

    ResultT Result;

    C(ResultT result);
};

template<typename T>
C<T>::C(ResultT result)
    : Result{result}
{
    return;
}

extern template class C<bool>;

void foo()
{
    C<bool> r(true);
}

It is absolutely necessary to use the std::same_as for the conditional. If it
is replaced with true (or false) everything works. Even exchanging it with
sizeof(T) >= 2 works. std::is_same_v also works.

So maybe it's a bug in std::same_as?

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

end of thread, other threads:[~2024-06-17 14:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-29 21:36 [Bug c++/115283] New: [14 Regression] "used but never defined" with extern templates gcc at hazardy dot de
2024-05-29 21:56 ` [Bug c++/115283] " mpolacek at gcc dot gnu.org
2024-05-29 22:42 ` [Bug c++/115283] [14/15 " pinskia at gcc dot gnu.org
2024-05-29 23:03 ` pinskia at gcc dot gnu.org
2024-05-29 23:04 ` pinskia at gcc dot gnu.org
2024-06-13  0:06 ` cvs-commit at gcc dot gnu.org
2024-06-13  2:20 ` [Bug c++/115283] [14 " ppalka at gcc dot gnu.org
2024-06-17 14:26 ` cvs-commit at gcc dot gnu.org
2024-06-17 14:26 ` ppalka at gcc dot gnu.org

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).