This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/78551] [5/6/7 Regression] Internal compiler error with constexpr initialization of union


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
      Known to work|                            |4.9.4
   Target Milestone|---                         |5.5
            Summary|Internal compiler error     |[5/6/7 Regression] Internal
                   |with constexpr              |compiler error with
                   |initialization of union     |constexpr initialization of
                   |                            |union
      Known to fail|                            |5.4.0, 6.2.0, 7.0

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
ICEs in

t.C:20:53: internal compiler error: in output_constructor_regular_field, at
varasm.c:4968
 constexpr std::array<A, 2> array({"long", "longer"});
                                                     ^

GCC 4.9 rejects it, so does clang++:

> clang++ t.C -S -std=gnu++14
t.C:20:28: error: constexpr variable 'array' must be initialized by a constant
      expression
constexpr std::array<A, 2> array({"long", "longer"});
                           ^~~~~~~~~~~~~~~~~~~~~~~~~
t.C:14:22: note: assignment to member 'buff' of union with active member 's' is
      not allowed in a constant expression
                                  buff[i] = str[i];
                                          ^
t.C:20:35: note: in call to 'A(&"long"[0])'
constexpr std::array<A, 2> array({"long", "longer"});
                                  ^
1 error generated.


Backtrace from GCC 6 branch head:

> /space/rguenther/install/gcc-6.2/bin/g++ t.ii -B /abuild/rguenther/gcc6-g/gcc
t.C:20:53: internal compiler error: in output_constructor_regular_field, at
varasm.c:4968
 constexpr std::array<A, 2> array({"long", "longer"});
                                                     ^
0x14386b5 output_constructor_regular_field
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:4968
0x14394c1 output_constructor
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:5276
0x1437f16 output_constant
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:4803
0x143897b output_constructor_regular_field
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:5006
0x14394c1 output_constructor
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:5276
0x1437f16 output_constant
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:4803
0x143897b output_constructor_regular_field
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:5006
0x14394c1 output_constructor
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:5276
0x1437bd8 output_constant
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:4773
0x143897b output_constructor_regular_field
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:5006
0x14394c1 output_constructor
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:5276
0x1437f16 output_constant
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:4803
0x142f4d9 assemble_variable_contents
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:2062
0x142fe82 assemble_variable(tree_node*, int, int, int)
        /space/rguenther/src/svn/gcc-6-branch/gcc/varasm.c:2238
0x1447096 varpool_node::assemble_decl()
        /space/rguenther/src/svn/gcc-6-branch/gcc/varpool.c:582
0xbb40d9 output_in_order
        /space/rguenther/src/svn/gcc-6-branch/gcc/cgraphunit.c:2231
0xbb4784 symbol_table::compile()
        /space/rguenther/src/svn/gcc-6-branch/gcc/cgraphunit.c:2468
0xbb49c3 symbol_table::finalize_compilation_unit()
        /space/rguenther/src/svn/gcc-6-branch/gcc/cgraphunit.c:2564
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]