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

* [Bug c++/100079] [9/10/11 Regression] Non-type template parameter, itself a nested template, rejected with internal error
  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 ` jakub at gcc dot gnu.org
  2021-04-14 13:24 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-14 13:18 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Non-type template           |[9/10/11 Regression]
                   |parameter, itself a nested  |Non-type template
                   |template, rejected with     |parameter, itself a nested
                   |internal error              |template, rejected with
                   |                            |internal error
   Target Milestone|---                         |9.4
   Last reconfirmed|                            |2021-04-14
                 CC|                            |jakub at gcc dot gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Priority|P3                          |P2

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
ICEs since r9-3836-g4be5c72cf3ea3ee98a97ac2e53d21122ad224b10
Before that is has been rejected with 
pr100079.C:23:28: error: ‘struct Bar<Baz<42> >’ is not a valid type for a
template non-type parameter
   23 | const Foo<Bar<Baz<42>>{baz}> test{};
      |                            ^

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

* [Bug c++/100079] [9/10/11 Regression] Non-type template parameter, itself a nested template, rejected with internal error
  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
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-14 13:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I'd say it is valid rather than invalid, it is accepted with
// using SomeTypeAlias = int;
and clang++ on godbolt accepts it in c++20 mode too.

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

* [Bug c++/100079] [9/10/11 Regression] Non-type template parameter, itself a nested template, rejected with internal error
  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
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mail at lboeger dot de @ 2021-04-14 16:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Lukas Böger <mail at lboeger dot de> ---
I believe it should be valid. The revision which turns the snippet from
rejection into an ICE makes sense, as this is about class-type instances as
non-type template parameters.

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

* [Bug c++/100079] [9/10/11 Regression] Non-type template parameter, itself a nested template, rejected with internal error
  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
                   ` (2 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-14 21:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org

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

* [Bug c++/100079] [9/10/11 Regression] Non-type template parameter, itself a nested template, rejected with internal error
  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
                   ` (3 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-16  5:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:89c863488bc8c7315596bcb753173aa2fd8be727

commit r11-8207-g89c863488bc8c7315596bcb753173aa2fd8be727
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 14 17:27:19 2021 -0400

    c++: C++20 class NTTP trailing zero-init [PR100079]

    The new testcase was breaking because constexpr evaluation was simplifying
    Bar{Baz<42>{}} to Bar{empty}, but then we weren't treating them as
    equivalent.  Poking at this revealed that the code for eliding trailing
    zero-initialization in class non-type template argument mangling was pretty
    broken, including the test, mangle71.

    I dealt with the FIXME to support RANGE_EXPR, and fixed the confusion
    between a list-initialized temporary mangled as written (i.e. in the
    signature of a function template) and a template parameter object mangled
as
    the value representation of the object.  I'm distinguishing between these
    using COMPOUND_LITERAL_P.  A later patch will adjust the use of
    COMPOUND_LITERAL_P to be more useful for this distinction, but it works now
    for distinguishing these cases in mangling.

    gcc/cp/ChangeLog:

            PR c++/100079
            * cp-tree.h (first_field): Declare.
            * mangle.c (range_expr_nelts): New.
            (write_expression): Improve class NTTP mangling.
            * pt.c (get_template_parm_object): Clear TREE_HAS_CONSTRUCTOR.
            * tree.c (zero_init_expr_p): Improve class NTTP handling.
            * decl.c: Adjust comment.

    gcc/testsuite/ChangeLog:

            PR c++/100079
            * g++.dg/abi/mangle71.C: Fix expected mangling.
            * g++.dg/abi/mangle77.C: New test.
            * g++.dg/cpp2a/nontype-class-union1.C: Likewise.
            * g++.dg/cpp2a/nontype-class-equiv1.C: Removed.
            * g++.dg/cpp2a/nontype-class44.C: New test.

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

* [Bug c++/100079] [9/10 Regression] Non-type template parameter, itself a nested template, rejected with internal error
  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
                   ` (4 preceding siblings ...)
  2021-04-16  5:17 ` cvs-commit at gcc dot gnu.org
@ 2021-04-16 14:05 ` jason at gcc dot gnu.org
  2021-04-20 18:53 ` mail at lboeger dot de
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-16 14:05 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |11.0
            Summary|[9/10/11 Regression]        |[9/10 Regression] Non-type
                   |Non-type template           |template parameter, itself
                   |parameter, itself a nested  |a nested template, rejected
                   |template, rejected with     |with internal error
                   |internal error              |
           Keywords|ice-on-invalid-code         |ice-on-valid-code

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for GCC 11.  I'm reluctant to backport this, since it significantly
changes the mangling of C++20 class NTTPs, but am open to it if desired by
C++20 users.

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

* [Bug c++/100079] [9/10 Regression] Non-type template parameter, itself a nested template, rejected with internal error
  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
                   ` (5 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: mail at lboeger dot de @ 2021-04-20 18:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Lukas Böger <mail at lboeger dot de> ---
Impressive responsiveness - big thank you for fixing this immediately!

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

* [Bug c++/100079] [9/10 Regression] Non-type template parameter, itself a nested template, rejected with internal error
  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
                   ` (6 preceding siblings ...)
  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
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01  8:20 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.4                         |9.5

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.

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

* [Bug c++/100079] [9/10 Regression] Non-type template parameter, itself a nested template, rejected with internal error
  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
                   ` (7 preceding siblings ...)
  2021-06-01  8:20 ` rguenth at gcc dot gnu.org
@ 2022-05-13 15:21 ` jason at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-13 15:21 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|9.5                         |11.0

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Not backporting.

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