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

            Bug ID: 80135
           Summary: [6/7 Regression] ICE in
                    output_constructor_regular_field, at varasm.c:4968
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The test case below (copied from bug 68489 comment #1) causes an ICE with this
week's top of trunk (GCC 7.0).  The same ICE is the subject of bug 78572 that
bug has been fixed on trunk (and the test case for it passes).  Same as bug
78572, the ICE here was introduced by r234636.

$ cat y.C && gcc -Wall -Wextra -Wpedantic y.C
struct S { char x; int y []; };

struct S s[2] = {
    { 1, { 2, 3 } },
    { 4, { 5, 6 } }
};

int main (void) {
    __builtin_printf ("sizeof s = %zu\n"
                      "s[0] @%p = { %hhi, { %i, %i } }\n"
                      "s[1] @%p = { %hhi, { %i, %i } }\n",
                      sizeof (struct S),
                      &s [0], s[0].x, s[0].y [0], s[0].y [1],
                      &s [1], s[1].x, s[1].y [0], s[1].y [1]);

    if (   s [0].x != 1 || s [0].y [0] != 2 || s [0].y [1] != 3
        || s [1].x != 4 || s [1].y [0] != 5 || s [1].y [1] != 6)
        __builtin_abort ();
}
y.C:1:27: warning: ISO C++ forbids flexible array member ‘y’ [-Wpedantic]
 struct S { char x; int y []; };
                           ^
y.C:6:1: warning: initialization of a flexible array member [-Wpedantic]
 };
 ^
y.C:6:1: warning: initialization of a flexible array member [-Wpedantic]
y.C: In function ‘int main()’:
y.C:14:61: warning: format ‘%p’ expects argument of type ‘void*’, but argument
3 has type ‘S*’ [-Wformat=]
                       &s [0], s[0].x, s[0].y [0], s[0].y [1],
                       ~~~~~~                                 
                       &s [1], s[1].x, s[1].y [0], s[1].y [1]);
                                                             ^
y.C:14:61: warning: format ‘%p’ expects argument of type ‘void*’, but argument
7 has type ‘S*’ [-Wformat=]
y.C: At global scope:
y.C:19:1: internal compiler error: in output_constructor_regular_field, at
varasm.c:5023
 }
 ^
0x15469c4 output_constructor_regular_field
        /src/gcc/git/gcc/varasm.c:5023
0x15477f4 output_constructor
        /src/gcc/git/gcc/varasm.c:5331
0x1545efa output_constant
        /src/gcc/git/gcc/varasm.c:4828
0x153d3f9 assemble_variable_contents
        /src/gcc/git/gcc/varasm.c:2083
0x153de56 assemble_variable(tree_node*, int, int, int)
        /src/gcc/git/gcc/varasm.c:2259
0x1555a78 varpool_node::assemble_decl()
        /src/gcc/git/gcc/varpool.c:588
0xc1f18c output_in_order
        /src/gcc/git/gcc/cgraphunit.c:2285
0xc1f857 symbol_table::compile()
        /src/gcc/git/gcc/cgraphunit.c:2525
0xc1faa8 symbol_table::finalize_compilation_unit()
        /src/gcc/git/gcc/cgraphunit.c:2621
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to