This seems to be a recent regression as the code is accepted by 7.2.0. $ g++tk -v Using built-in specs. COLLECT_GCC=g++tk COLLECT_LTO_WRAPPER=/home/su/software/tmp/gcc/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/8.0.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-source-trunk/configure --enable-languages=c,c++,lto --prefix=/home/su/software/tmp/gcc/gcc-trunk --disable-bootstrap Thread model: posix gcc version 8.0.1 20180216 (experimental) [trunk revision 257739] (GCC) $ $ g++-7.2.0 -c tmp.cpp $ $ g++tk -c tmp.cpp tmp.cpp:4:42: internal compiler error: tree check: expected record_type or union_type or qual_union_type, have vector_type in reduced_constant_expression_p, at cp/constexpr.c:1766 constexpr vec v = __builtin_shuffle (v, u); ^ 0x63cd06 tree_check_failed(tree_node const*, char const*, int, char const*, ...) ../../gcc-source-trunk/gcc/tree.c:9337 0x70aefc tree_check3(tree_node*, char const*, int, char const*, tree_code, tree_code, tree_code) ../../gcc-source-trunk/gcc/tree.h:3172 0x70aefc reduced_constant_expression_p(tree_node*) ../../gcc-source-trunk/gcc/cp/constexpr.c:1766 0x70af64 verify_constant ../../gcc-source-trunk/gcc/cp/constexpr.c:1809 0x71267b cxx_eval_trinary_expression ../../gcc-source-trunk/gcc/cp/constexpr.c:3378 0x71267b cxx_eval_constant_expression ../../gcc-source-trunk/gcc/cp/constexpr.c:4526 0x71954d cxx_eval_outermost_constant_expr ../../gcc-source-trunk/gcc/cp/constexpr.c:4801 0x92a5a2 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int) ../../gcc-source-trunk/gcc/cp/typeck2.c:833 0x750492 check_initializer ../../gcc-source-trunk/gcc/cp/decl.c:6378 0x778871 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int) ../../gcc-source-trunk/gcc/cp/decl.c:7032 0x83428d cp_parser_init_declarator ../../gcc-source-trunk/gcc/cp/parser.c:19705 0x835f1f cp_parser_simple_declaration ../../gcc-source-trunk/gcc/cp/parser.c:13046 0x836e68 cp_parser_block_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12864 0x842c84 cp_parser_declaration ../../gcc-source-trunk/gcc/cp/parser.c:12761 0x841606 cp_parser_declaration_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:12637 0x841923 cp_parser_translation_unit ../../gcc-source-trunk/gcc/cp/parser.c:4559 0x841923 c_parse_file() ../../gcc-source-trunk/gcc/cp/parser.c:38860 0x98a825 c_common_parse_file() ../../gcc-source-trunk/gcc/c-family/c-opts.c:1132 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. $ ------------------------------------------------------------------ typedef int vec __attribute__ ((vector_size (2 * sizeof (int)))); constexpr vec u = { 1, 2 }; constexpr vec v = __builtin_shuffle (v, u);
I can confirm it with r257668 but not with the top of trunk (r257768). The regression was introduced in r251948. I vaguely remember a bug with a test case similar to this one go by but I can't find it. Can you please retry with a newer revision and report back?
(In reply to Martin Sebor from comment #1) > I can confirm it with r257668 but not with the top of trunk (r257768). The > regression was introduced in r251948. I vaguely remember a bug with a test > case similar to this one go by but I can't find it. Can you please retry > with a newer revision and report back? My latest build is r257757, which still ICEs on this test. I am building the top of the trunk.
I can reproduce with latest trunk too. The ICE is on: 1765 if (CONSTRUCTOR_NO_IMPLICIT_ZERO (t)) 1766 field = next_initializable_field (TYPE_FIELDS (TREE_TYPE (t))); 1767 else 1768 field = NULL_TREE; where t is: <constructor 0x7fffefdb3228 type <vector_type 0x7fffefd9f9d8 vec type <integer_type 0x7fffefc625e8 int public type_6 SI size <integer_cst 0x7fffefc650c0 constant 32> unit-size <integer_cst 0x7fffefc650d8 constant 4> align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffefc625e8 precision:32 min <integer_cst 0x7fffefc65078 -2147483648> max <integer_cst 0x7fffefc65090 2147483647> pointer_to_this <pointer_type 0x7fffefc6aa80>> V2SI size <integer_cst 0x7fffefc45e70 constant 64> unit-size <integer_cst 0x7fffefc45e88 constant 8> align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffefd72d20 nunits:2> constant tree_1 length:0> created in: 4783 if (AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type)) 4784 { 4785 /* In C++14 an NSDMI can participate in aggregate initialization, 4786 and can refer to the address of the object being initialized, so 4787 we need to pass in the relevant VAR_DECL if we want to do the 4788 evaluation in a single pass. The evaluation will dynamically 4789 update ctx.values for the VAR_DECL. We use the same strategy 4790 for C++11 constexpr constructors that refer to the object being 4791 initialized. */ 4792 ctx.ctor = build_constructor (type, NULL); 4793 CONSTRUCTOR_NO_IMPLICIT_ZERO (ctx.ctor) = true; VECTOR_TYPE obviously doesn't have TYPE_FIELDS. I guess we need to teach reduced_constant_expression_p how to handle VECTOR_TYPE constructors.
Fixed.
Author: jason Date: Thu Feb 22 22:50:37 2018 New Revision: 257924 URL: https://gcc.gnu.org/viewcvs?rev=257924&root=gcc&view=rev Log: PR c++/84424 - ICE with constexpr and __builtin_shuffle. * constexpr.c (reduced_constant_expression_p): Handle CONSTRUCTOR of VECTOR_TYPE. Added: trunk/gcc/testsuite/g++.dg/ext/vector34.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/constexpr.c