The following C++11 code causes an ICE when compiled with the current GCC trunk on x86_64-linux-gnu in both 32-bit and 64-bit modes. This is a regression from 6.1.x. $ g++-trunk -v Using built-in specs. COLLECT_GCC=g++-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/usr/local/gcc-trunk --disable-bootstrap Thread model: posix gcc version 7.0.0 20160709 (experimental) [trunk revision 238191] (GCC) $ $ g++-6.1 -c small.cpp $ $ g++-trunk -c small.cpp small.cpp:3:44: internal compiler error: in operand_equal_p, at fold-const.c:2790 static_assert (& __imag a == &__real a, ""); ^ 0xab89b0 operand_equal_p(tree_node const*, tree_node const*, unsigned int) ../../gcc-source-trunk/gcc/fold-const.c:2790 0xab70e9 operand_equal_p(tree_node const*, tree_node const*, unsigned int) ../../gcc-source-trunk/gcc/fold-const.c:2951 0xab6cbf operand_equal_p(tree_node const*, tree_node const*, unsigned int) ../../gcc-source-trunk/gcc/fold-const.c:2749 0x1226391 generic_simplify_EQ_EXPR /tmp/gcc-builder/gcc-build-trunk/gcc/generic-match.c:27436 0x122ab55 generic_simplify(unsigned int, tree_code, tree_node*, tree_node*, tree_node*) /tmp/gcc-builder/gcc-build-trunk/gcc/generic-match.c:31021 0xac73f7 fold_binary_loc(unsigned int, tree_code, tree_node*, tree_node*, tree_node*) ../../gcc-source-trunk/gcc/fold-const.c:9161 0x8aeba8 cxx_eval_binary_expression ../../gcc-source-trunk/gcc/cp/constexpr.c:1816 0x8ab4d7 cxx_eval_constant_expression ../../gcc-source-trunk/gcc/cp/constexpr.c:3885 0x8b1ec9 cxx_eval_outermost_constant_expr ../../gcc-source-trunk/gcc/cp/constexpr.c:4211 0x8b4ec8 maybe_constant_value_1 ../../gcc-source-trunk/gcc/cp/constexpr.c:4405 0x8b4ec8 maybe_constant_value(tree_node*, tree_node*) ../../gcc-source-trunk/gcc/cp/constexpr.c:4429 0x81ded5 finish_static_assert(tree_node*, tree_node*, unsigned int, bool) ../../gcc-source-trunk/gcc/cp/semantics.c:8749 0x79c370 cp_parser_static_assert ../../gcc-source-trunk/gcc/cp/parser.c:13056 0x7ae489 cp_parser_block_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12247 0x7b6d50 cp_parser_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12148 0x7b5824 cp_parser_declaration_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:12027 0x7b5b58 cp_parser_translation_unit ../../gcc-source-trunk/gcc/cp/parser.c:4329 0x7b5b58 c_parse_file() ../../gcc-source-trunk/gcc/cp/parser.c:37505 0x919dc2 c_common_parse_file() ../../gcc-source-trunk/gcc/c-family/c-opts.c:1070 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. $ ------------------------------------------------- constexpr _Complex int a {1, 1}; static_assert (& __imag a == &__real a, "");
The ICE was apparently introduced by r230365: r230365 | jason | 2015-11-13 19:08:05 -0500 (Fri, 13 Nov 2015) | 59 lines Merge C++ delayed folding branch. Prior to that, the program failed to compile with: error: static assertion failed static_assert (& __imag a == &__real a, ""); ^~~~~~~~~~~~~
Created attachment 38872 [details] gcc7-pr71828.patch Untested fix.
Author: jakub Date: Mon Jul 18 18:43:19 2016 New Revision: 238442 URL: https://gcc.gnu.org/viewcvs?rev=238442&root=gcc&view=rev Log: PR c++/71828 * constexpr.c (cxx_eval_constant_expression) <case REALPART_EXPR>: For lval don't use cxx_eval_unary_expression and instead recurse and if needed rebuild the reference. * g++.dg/cpp0x/constexpr-71828.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-71828.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/constexpr.c trunk/gcc/testsuite/ChangeLog
Author: jakub Date: Tue Jul 19 08:44:04 2016 New Revision: 238460 URL: https://gcc.gnu.org/viewcvs?rev=238460&root=gcc&view=rev Log: Backported from mainline 2016-07-18 Jakub Jelinek <jakub@redhat.com> PR c++/71828 * constexpr.c (cxx_eval_constant_expression) <case REALPART_EXPR>: For lval don't use cxx_eval_unary_expression and instead recurse and if needed rebuild the reference. * g++.dg/cpp0x/constexpr-71828.C: New test. Added: branches/gcc-6-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-71828.C Modified: branches/gcc-6-branch/gcc/cp/ChangeLog branches/gcc-6-branch/gcc/cp/constexpr.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
Fixed.