public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100079] New: Non-type template parameter, itself a nested template, rejected with internal error
@ 2021-04-14 12:54 mail at lboeger dot de
  2021-04-14 13:18 ` [Bug c++/100079] [9/10/11 Regression] " jakub at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: mail at lboeger dot de @ 2021-04-14 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100079
           Summary: Non-type template parameter, itself a nested template,
                    rejected with internal error
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mail at lboeger dot de
  Target Milestone: ---

The following snippet triggers an internal compiler error.



template <auto value>
struct Foo {
    using SomeTypeAlias = int;

    Foo()
    {}
};

template <class T>
struct Bar {
    T value;

    constexpr Bar(const T& value)
        : value{value}
    {}
};

template <int N>
struct Baz {};

constexpr auto baz = Baz<42>{};

const Foo<Bar<Baz<42>>{baz}> test{};



test.cpp: In instantiation of 'struct Foo<Bar<Baz<42> >()>':
test.cpp:6:5:   required from 'Foo<value>::Foo() [with auto value = Bar<Baz<42>
>{Baz<42>()}]'
test.cpp:24:35:   required from here
test.cpp:3:12: internal compiler error: in finish_member_declaration, at
cp/semantics.c:3237
    3 | struct Foo {
      |            ^


Interestingly, when removing the type alias Foo::SomeTypeAlias, this compiles
as expected. In addition, defaulting the Foo constructor yields a different
diagnostic:


test.cpp: In instantiation of 'struct Foo<Bar<Baz<42> >{Baz<42>()}>':
test.cpp:24:30:   required from here
test.cpp:6:5: error: defaulted declaration 'Foo<value>::Foo() [with auto value
= Bar<Baz<42> >{Baz<42>()}]' does not match the expected signature
    6 |     Foo() = default;
      |     ^~~
test.cpp:6:5: note: expected signature: 'constexpr Foo<Bar<Baz<42>
>{Baz<42>()}>::Foo()'



These results were produced with gcc-10.2.0_4 on MacOS, but it seems to be the
same in 10.3 and trunk (see https://godbolt.org/z/PexPbq6cf)

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

end of thread, other threads:[~2022-05-13 15:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14 12:54 [Bug c++/100079] New: Non-type template parameter, itself a nested template, rejected with internal error mail at lboeger dot de
2021-04-14 13:18 ` [Bug c++/100079] [9/10/11 Regression] " jakub at gcc dot gnu.org
2021-04-14 13:24 ` jakub at gcc dot gnu.org
2021-04-14 16:54 ` mail at lboeger dot de
2021-04-14 21:33 ` jason at gcc dot gnu.org
2021-04-16  5:17 ` cvs-commit at gcc dot gnu.org
2021-04-16 14:05 ` [Bug c++/100079] [9/10 " jason at gcc dot gnu.org
2021-04-20 18:53 ` mail at lboeger dot de
2021-06-01  8:20 ` rguenth at gcc dot gnu.org
2022-05-13 15:21 ` jason 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).