public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109387] New: "definition of explicitly-defaulted" error with explicit template instantiation
@ 2023-04-03  8:22 vittorio.romeo at outlook dot com
  2023-04-04  0:57 ` [Bug c++/109387] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: vittorio.romeo at outlook dot com @ 2023-04-03  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109387
           Summary: "definition of explicitly-defaulted" error with
                    explicit template instantiation
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vittorio.romeo at outlook dot com
  Target Milestone: ---

Given this code:

    template <typename> struct S { S(); };
    // extern template struct S<int>;
    template <typename T> S<T>::S() = default;
    template S<int>::S();

GCC fails to compile with this error:

    error: definition of explicitly-defaulted 'S< <template-parameter-1-1>
>::S() 
           [with <template-parameter-1-1> = int]'
        3 | template <typename T> S<T>::S() = default;
          |                       ^~~~

Uncommenting the extern template fixes compilation. Clang compiles the original
code without any issue.

Live example on Compiler Explorer: 
- https://gcc.godbolt.org/z/YoPhvKnxa

Related StackOverflow thread:
- https://stackoverflow.com/questions/75913223

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

* [Bug c++/109387] "definition of explicitly-defaulted" error with explicit template instantiation
  2023-04-03  8:22 [Bug c++/109387] New: "definition of explicitly-defaulted" error with explicit template instantiation vittorio.romeo at outlook dot com
@ 2023-04-04  0:57 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-04  0:57 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-04-04
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

end of thread, other threads:[~2023-04-04  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03  8:22 [Bug c++/109387] New: "definition of explicitly-defaulted" error with explicit template instantiation vittorio.romeo at outlook dot com
2023-04-04  0:57 ` [Bug c++/109387] " pinskia 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).