public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103968] New: ICE and segfault when instantiating template with lvalue ref argument and nested template type
@ 2022-01-10 19:13 aliaume.morel at baracoda dot com
  2022-01-10 19:30 ` [Bug c++/103968] [11/12 Regression] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: aliaume.morel at baracoda dot com @ 2022-01-10 19:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103968
           Summary: ICE and segfault when instantiating template with
                    lvalue ref argument and nested template type
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: aliaume.morel at baracoda dot com
  Target Milestone: ---

The following compiles with clang, GCC 10.3, but gives an ICE on GCC 11.1 and
12.0.0 (20220110) - tested on Godbolt (https://godbolt.org/z/db5EjWGWa):

```
template <typename Opt, Opt const& options>
struct trait
{
    template <typename T>
    struct NonInstantiated{};
};

struct Options {};

template <typename T>
struct Widget
{
    static constexpr auto c_options = Options{};
    using Trait = trait<decltype(c_options), c_options>;
};

Widget<int>::Trait b{}; // Crashes GCC > 10.3
```


Stack trace:
<source>: In instantiation of 'struct trait<const Options, ((const
Options&)Widget<T>::c_options)>':
<source>:17:20:   required from here
<source>:5:12: internal compiler error: Segmentation fault
    5 |     struct NonInstantiated{};
      |            ^~~~~~~~~~~~~~~
0x1780bf9 internal_error(char const*, ...)
        ???:0
0x7f628d instantiate_class_template(tree_node*)
        ???:0
0x829553 complete_type(tree_node*)
        ???:0
0x6e6d2b start_decl_1(tree_node*, bool)
        ???:0
0x6f6587 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ???:0
0x7c0cab c_parse_file()
        ???:0
0x892aa2 c_common_parse_file()
        ???:0


- This is reproducible in C++17 and C++20 mode.
- In C++20 mode, removing the lvalue ref from the second template argument in
`struct trait` doesn't trigger the ICE and builds successfully.
- If `Widget` is a non-template type, it doesn't trigger the ICE and builds
succesfully.

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

* [Bug c++/103968] [11/12 Regression] ICE and segfault when instantiating template with lvalue ref argument and nested template type
  2022-01-10 19:13 [Bug c++/103968] New: ICE and segfault when instantiating template with lvalue ref argument and nested template type aliaume.morel at baracoda dot com
@ 2022-01-10 19:30 ` mpolacek at gcc dot gnu.org
  2022-01-11  8:41 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-01-10 19:30 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|                            |2022-01-10
             Status|UNCONFIRMED                 |NEW
            Summary|ICE and segfault when       |[11/12 Regression] ICE and
                   |instantiating template with |segfault when instantiating
                   |lvalue ref argument and     |template with lvalue ref
                   |nested template type        |argument and nested
                   |                            |template type
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.3

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r11-2748.

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

* [Bug c++/103968] [11/12 Regression] ICE and segfault when instantiating template with lvalue ref argument and nested template type
  2022-01-10 19:13 [Bug c++/103968] New: ICE and segfault when instantiating template with lvalue ref argument and nested template type aliaume.morel at baracoda dot com
  2022-01-10 19:30 ` [Bug c++/103968] [11/12 Regression] " mpolacek at gcc dot gnu.org
@ 2022-01-11  8:41 ` rguenth at gcc dot gnu.org
  2022-03-27  4:26 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-11  8:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/103968] [11/12 Regression] ICE and segfault when instantiating template with lvalue ref argument and nested template type
  2022-01-10 19:13 [Bug c++/103968] New: ICE and segfault when instantiating template with lvalue ref argument and nested template type aliaume.morel at baracoda dot com
  2022-01-10 19:30 ` [Bug c++/103968] [11/12 Regression] " mpolacek at gcc dot gnu.org
  2022-01-11  8:41 ` rguenth at gcc dot gnu.org
@ 2022-03-27  4:26 ` jason at gcc dot gnu.org
  2022-03-28 13:37 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-27  4:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/103968] [11/12 Regression] ICE and segfault when instantiating template with lvalue ref argument and nested template type
  2022-01-10 19:13 [Bug c++/103968] New: ICE and segfault when instantiating template with lvalue ref argument and nested template type aliaume.morel at baracoda dot com
                   ` (2 preceding siblings ...)
  2022-03-27  4:26 ` jason at gcc dot gnu.org
@ 2022-03-28 13:37 ` cvs-commit at gcc dot gnu.org
  2022-03-28 19:12 ` [Bug c++/103968] [11 " cvs-commit at gcc dot gnu.org
  2022-03-28 19:18 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-28 13:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:c7361eb36fa50307c9f7cfca36c9f58ce24f8f54

commit r12-7852-gc7361eb36fa50307c9f7cfca36c9f58ce24f8f54
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Mar 27 00:28:30 2022 -0400

    c++: member alias declaration [PR103968]

    Here, we were wrongly thinking that (const Options&)Widget<T>::c_options is
    not value-dependent because neither the type nor the (value of) c_options
    are dependent, but since we're binding it to a reference we also need to
    consider that it has a value-dependent address.

            PR c++/103968

    gcc/cp/ChangeLog:

            * pt.cc (value_dependent_expression_p): Check
            has_value_dependent_address for conversion to reference.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/alias-decl-mem1.C: New test.

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

* [Bug c++/103968] [11 Regression] ICE and segfault when instantiating template with lvalue ref argument and nested template type
  2022-01-10 19:13 [Bug c++/103968] New: ICE and segfault when instantiating template with lvalue ref argument and nested template type aliaume.morel at baracoda dot com
                   ` (3 preceding siblings ...)
  2022-03-28 13:37 ` cvs-commit at gcc dot gnu.org
@ 2022-03-28 19:12 ` cvs-commit at gcc dot gnu.org
  2022-03-28 19:18 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-28 19:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:97390a9914672f5ce73c169b3ae7fd4bba25c2fe

commit r11-9704-g97390a9914672f5ce73c169b3ae7fd4bba25c2fe
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Mar 27 00:28:30 2022 -0400

    c++: member alias declaration [PR103968]

    Here, we were wrongly thinking that (const Options&)Widget<T>::c_options is
    not value-dependent because neither the type nor the (value of) c_options
    are dependent, but since we're binding it to a reference we also need to
    consider that it has a value-dependent address.

            PR c++/103968

    gcc/cp/ChangeLog:

            * pt.c (value_dependent_expression_p): Check
            has_value_dependent_address for conversion to reference.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/alias-decl-mem1.C: New test.

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

* [Bug c++/103968] [11 Regression] ICE and segfault when instantiating template with lvalue ref argument and nested template type
  2022-01-10 19:13 [Bug c++/103968] New: ICE and segfault when instantiating template with lvalue ref argument and nested template type aliaume.morel at baracoda dot com
                   ` (4 preceding siblings ...)
  2022-03-28 19:12 ` [Bug c++/103968] [11 " cvs-commit at gcc dot gnu.org
@ 2022-03-28 19:18 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2022-03-28 19:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-03-28 19:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 19:13 [Bug c++/103968] New: ICE and segfault when instantiating template with lvalue ref argument and nested template type aliaume.morel at baracoda dot com
2022-01-10 19:30 ` [Bug c++/103968] [11/12 Regression] " mpolacek at gcc dot gnu.org
2022-01-11  8:41 ` rguenth at gcc dot gnu.org
2022-03-27  4:26 ` jason at gcc dot gnu.org
2022-03-28 13:37 ` cvs-commit at gcc dot gnu.org
2022-03-28 19:12 ` [Bug c++/103968] [11 " cvs-commit at gcc dot gnu.org
2022-03-28 19:18 ` 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).