public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95164] New: ICE regression starting with 9.3
@ 2020-05-16 14:30 boris_oncev at hotmail dot com
  2020-05-16 14:40 ` [Bug c++/95164] [9/10/11 Regression] " mpolacek at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: boris_oncev at hotmail dot com @ 2020-05-16 14:30 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95164
           Summary: ICE regression starting with 9.3
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: boris_oncev at hotmail dot com
  Target Milestone: ---

Reproduction code on godbolt, showing ICE on 9.3 & 10.1 but works fine on 9.2

https://godbolt.org/z/-Dr7Lc

#include <vector>

struct A { };
struct B {
  A a;
};

struct C { };
struct D {
  C c;
  B b;
};

struct E {
  D d;
};

template<class T>
struct F {
  F() {
    A a;
    A& a2 = a;

    std::vector<E> return_values;
    return_values.push_back({ {C{}, {B{a2}}} });
  }
};

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

* [Bug c++/95164] [9/10/11 Regression] ICE regression starting with 9.3
  2020-05-16 14:30 [Bug c++/95164] New: ICE regression starting with 9.3 boris_oncev at hotmail dot com
@ 2020-05-16 14:40 ` mpolacek at gcc dot gnu.org
  2020-05-17 20:08 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-16 14:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org
           Keywords|                            |ice-on-valid-code
             Status|UNCONFIRMED                 |ASSIGNED
   Target Milestone|---                         |9.4
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2020-05-16
            Summary|ICE regression starting     |[9/10/11 Regression] ICE
                   |with 9.3                    |regression starting with
                   |                            |9.3

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with my r10-5624-g14818f987abbb15c203043838e4ef9fbb20c783e

$ ./cc1plus -quiet 95164.ii
95164.C: In constructor ‘F<T>::F()’:
95164.C:25:47: internal compiler error: in reshape_init_class, at
cp/decl.c:6182
   25 |     return_values.push_back({ {C{}, {B{a2}}} });
      |                                               ^
0xa27fcd reshape_init_class
        /home/mpolacek/src/gcc/gcc/cp/decl.c:6182
0xa28f70 reshape_init_r
        /home/mpolacek/src/gcc/gcc/cp/decl.c:6462
0xa280da reshape_init_class
        /home/mpolacek/src/gcc/gcc/cp/decl.c:6210
0xa28f70 reshape_init_r
        /home/mpolacek/src/gcc/gcc/cp/decl.c:6462
0xa29230 reshape_init(tree_node*, tree_node*, int)
        /home/mpolacek/src/gcc/gcc/cp/decl.c:6528
0x92455c implicit_conversion
        /home/mpolacek/src/gcc/gcc/cp/call.c:2004
0x949fbe can_convert_arg(tree_node*, tree_node*, tree_node*, int, int)
        /home/mpolacek/src/gcc/gcc/cp/call.c:11807
0x920dce build_aggr_conv
        /home/mpolacek/src/gcc/gcc/cp/call.c:1026
0x924c95 implicit_conversion
        /home/mpolacek/src/gcc/gcc/cp/call.c:2071
0x923f94 reference_binding
        /home/mpolacek/src/gcc/gcc/cp/call.c:1912
0x9245d2 implicit_conversion
        /home/mpolacek/src/gcc/gcc/cp/call.c:2011
0x926845 add_function_candidate
        /home/mpolacek/src/gcc/gcc/cp/call.c:2408
0x932bdd add_candidates
        /home/mpolacek/src/gcc/gcc/cp/call.c:5881
0x943a77 build_new_method_call_1
        /home/mpolacek/src/gcc/gcc/cp/call.c:10235
0x944907 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        /home/mpolacek/src/gcc/gcc/cp/call.c:10442
0xb36aed cp_parser_postfix_expression
        /home/mpolacek/src/gcc/gcc/cp/parser.c:7436
0xb3969a cp_parser_unary_expression
        /home/mpolacek/src/gcc/gcc/cp/parser.c:8565
0xb3ab04 cp_parser_cast_expression
        /home/mpolacek/src/gcc/gcc/cp/parser.c:9456
0xb3abf1 cp_parser_binary_expression
        /home/mpolacek/src/gcc/gcc/cp/parser.c:9559
0xb3ba32 cp_parser_assignment_expression
        /home/mpolacek/src/gcc/gcc/cp/parser.c:9864

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

* [Bug c++/95164] [9/10/11 Regression] ICE regression starting with 9.3
  2020-05-16 14:30 [Bug c++/95164] New: ICE regression starting with 9.3 boris_oncev at hotmail dot com
  2020-05-16 14:40 ` [Bug c++/95164] [9/10/11 Regression] " mpolacek at gcc dot gnu.org
@ 2020-05-17 20:08 ` mpolacek at gcc dot gnu.org
  2020-05-18  0:41 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-17 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
It actually started with r5-7-g1c982d13138ee4518db10b6fbe02fa32d09ab51e -- it
was latent for a while.

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

* [Bug c++/95164] [9/10/11 Regression] ICE regression starting with 9.3
  2020-05-16 14:30 [Bug c++/95164] New: ICE regression starting with 9.3 boris_oncev at hotmail dot com
  2020-05-16 14:40 ` [Bug c++/95164] [9/10/11 Regression] " mpolacek at gcc dot gnu.org
  2020-05-17 20:08 ` mpolacek at gcc dot gnu.org
@ 2020-05-18  0:41 ` mpolacek at gcc dot gnu.org
  2020-05-18  5:59 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-18  0:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
struct H {
  int a;
};
struct I {
  int c;
  H b;
};
struct E { I d; };
void foo(E);

template<typename>
void fn ()
{
  int a = 42;
  int &k = a;
  foo({1, {H{k}}});
}

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

* [Bug c++/95164] [9/10/11 Regression] ICE regression starting with 9.3
  2020-05-16 14:30 [Bug c++/95164] New: ICE regression starting with 9.3 boris_oncev at hotmail dot com
                   ` (2 preceding siblings ...)
  2020-05-18  0:41 ` mpolacek at gcc dot gnu.org
@ 2020-05-18  5:59 ` rguenth at gcc dot gnu.org
  2020-09-04 21:40 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-18  5:59 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |9.3.0
      Known to work|                            |9.2.0
           Priority|P3                          |P2

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

* [Bug c++/95164] [9/10/11 Regression] ICE regression starting with 9.3
  2020-05-16 14:30 [Bug c++/95164] New: ICE regression starting with 9.3 boris_oncev at hotmail dot com
                   ` (3 preceding siblings ...)
  2020-05-18  5:59 ` rguenth at gcc dot gnu.org
@ 2020-09-04 21:40 ` mpolacek at gcc dot gnu.org
  2020-09-09 21:41 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-04 21:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Patch posted:
https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553311.html

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

* [Bug c++/95164] [9/10/11 Regression] ICE regression starting with 9.3
  2020-05-16 14:30 [Bug c++/95164] New: ICE regression starting with 9.3 boris_oncev at hotmail dot com
                   ` (4 preceding siblings ...)
  2020-09-04 21:40 ` mpolacek at gcc dot gnu.org
@ 2020-09-09 21:41 ` cvs-commit at gcc dot gnu.org
  2020-09-09 21:42 ` cvs-commit at gcc dot gnu.org
  2020-09-09 21:43 ` [Bug c++/95164] [9 " mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-09 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:acbe30bbc884899da72df47d023ebde89f8f47f1

commit r11-3091-gacbe30bbc884899da72df47d023ebde89f8f47f1
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Sep 4 16:04:26 2020 -0400

    c++: Fix ICE in reshape_init with init-list [PR95164]

    This patch fixes a long-standing bug in reshape_init_r.  Since r209314
    we implement DR 1467 which handles list-initialization with a single
    initializer of the same type as the target.  In this test this causes
    a crash in reshape_init_r when we're processing a constructor that has
    undergone the DR 1467 transformation.

    Take e.g. the

      foo({{1, {H{k}}}});

    line in the attached test.  {H{k}} initializes the field b of H in I.
    H{k} is a functional cast, so has TREE_HAS_CONSTRUCTOR set, so is
    COMPOUND_LITERAL_P.  We perform the DR 1467 transformation and turn
    {H{k}} into H{k}.  Then we attempt to reshape H{k} again and since
    first_initializer_p is null and it's COMPOUND_LITERAL_P, we go here:

               else if (COMPOUND_LITERAL_P (stripped_init))
                 gcc_assert (!BRACE_ENCLOSED_INITIALIZER_P (stripped_init));

    then complain about the missing braces, go to reshape_init_class and ICE
    on
                   gcc_checking_assert (d->cur->index
                                        == get_class_binding (type, id));

    because due to the missing { } we're looking for 'b' in H, but that's
    not found.

    So we have to be prepared to handle an initializer whose outer braces
    have been removed due to DR 1467.

    gcc/cp/ChangeLog:

            PR c++/95164
            * decl.c (reshape_init_r): When initializing an aggregate member
            with an initializer from an initializer-list, also consider
            COMPOUND_LITERAL_P.

    gcc/testsuite/ChangeLog:

            PR c++/95164
            * g++.dg/cpp0x/initlist123.C: New test.

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

* [Bug c++/95164] [9/10/11 Regression] ICE regression starting with 9.3
  2020-05-16 14:30 [Bug c++/95164] New: ICE regression starting with 9.3 boris_oncev at hotmail dot com
                   ` (5 preceding siblings ...)
  2020-09-09 21:41 ` cvs-commit at gcc dot gnu.org
@ 2020-09-09 21:42 ` cvs-commit at gcc dot gnu.org
  2020-09-09 21:43 ` [Bug c++/95164] [9 " mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-09-09 21:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:f63831405a32287dea2862ce3663675cc5b55180

commit r10-8723-gf63831405a32287dea2862ce3663675cc5b55180
Author: Marek Polacek <polacek@redhat.com>
Date:   Fri Sep 4 16:04:26 2020 -0400

    c++: Fix ICE in reshape_init with init-list [PR95164]

    This patch fixes a long-standing bug in reshape_init_r.  Since r209314
    we implement DR 1467 which handles list-initialization with a single
    initializer of the same type as the target.  In this test this causes
    a crash in reshape_init_r when we're processing a constructor that has
    undergone the DR 1467 transformation.

    Take e.g. the

      foo({{1, {H{k}}}});

    line in the attached test.  {H{k}} initializes the field b of H in I.
    H{k} is a functional cast, so has TREE_HAS_CONSTRUCTOR set, so is
    COMPOUND_LITERAL_P.  We perform the DR 1467 transformation and turn
    {H{k}} into H{k}.  Then we attempt to reshape H{k} again and since
    first_initializer_p is null and it's COMPOUND_LITERAL_P, we go here:

               else if (COMPOUND_LITERAL_P (stripped_init))
                 gcc_assert (!BRACE_ENCLOSED_INITIALIZER_P (stripped_init));

    then complain about the missing braces, go to reshape_init_class and ICE
    on
                   gcc_checking_assert (d->cur->index
                                        == get_class_binding (type, id));

    because due to the missing { } we're looking for 'b' in H, but that's
    not found.

    So we have to be prepared to handle an initializer whose outer braces
    have been removed due to DR 1467.

    gcc/cp/ChangeLog:

            PR c++/95164
            * decl.c (reshape_init_r): When initializing an aggregate member
            with an initializer from an initializer-list, also consider
            COMPOUND_LITERAL_P.

    gcc/testsuite/ChangeLog:

            PR c++/95164
            * g++.dg/cpp0x/initlist123.C: New test.

    (cherry picked from commit acbe30bbc884899da72df47d023ebde89f8f47f1)

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

* [Bug c++/95164] [9 Regression] ICE regression starting with 9.3
  2020-05-16 14:30 [Bug c++/95164] New: ICE regression starting with 9.3 boris_oncev at hotmail dot com
                   ` (6 preceding siblings ...)
  2020-09-09 21:42 ` cvs-commit at gcc dot gnu.org
@ 2020-09-09 21:43 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-09 21:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
            Summary|[9/10/11 Regression] ICE    |[9 Regression] ICE
                   |regression starting with    |regression starting with
                   |9.3                         |9.3
         Resolution|---                         |FIXED

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2020-09-09 21:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 14:30 [Bug c++/95164] New: ICE regression starting with 9.3 boris_oncev at hotmail dot com
2020-05-16 14:40 ` [Bug c++/95164] [9/10/11 Regression] " mpolacek at gcc dot gnu.org
2020-05-17 20:08 ` mpolacek at gcc dot gnu.org
2020-05-18  0:41 ` mpolacek at gcc dot gnu.org
2020-05-18  5:59 ` rguenth at gcc dot gnu.org
2020-09-04 21:40 ` mpolacek at gcc dot gnu.org
2020-09-09 21:41 ` cvs-commit at gcc dot gnu.org
2020-09-09 21:42 ` cvs-commit at gcc dot gnu.org
2020-09-09 21:43 ` [Bug c++/95164] [9 " mpolacek 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).