https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83058
Bug ID: 83058 Summary: ICE on C++ code with negative array index: in warn_placement_new_too_small, at cp/init.c:2666 Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: su at cs dot ucdavis.edu Target Milestone: --- This appears to be a recent regression. $ 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.0/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.0 20171119 (experimental) [trunk revision 254940] (GCC) $ $ g++-7.2.0 -c -w tmp.cpp $ clang++ -c -w tmp.cpp $ icc -c -w tmp.cpp $ $ g++tk -c -w tmp.cpp tmp.cpp: In member function ‘void B::f()’: tmp.cpp:7:31: internal compiler error: in warn_placement_new_too_small, at cp/init.c:2666 void f () { new (&d[-1]) A (); } ^ 0x79f563 warn_placement_new_too_small ../../gcc-source-trunk/gcc/cp/init.c:2666 0x7a858e build_new_1 ../../gcc-source-trunk/gcc/cp/init.c:3209 0x7a99b8 build_new(vec<tree_node*, va_gc, vl_embed>**, tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int, int) ../../gcc-source-trunk/gcc/cp/init.c:3678 0x81f7c6 cp_parser_new_expression ../../gcc-source-trunk/gcc/cp/parser.c:8517 0x82ba67 cp_parser_unary_expression ../../gcc-source-trunk/gcc/cp/parser.c:8223 0x7fafcc cp_parser_cast_expression ../../gcc-source-trunk/gcc/cp/parser.c:9131 0x7fb733 cp_parser_binary_expression ../../gcc-source-trunk/gcc/cp/parser.c:9232 0x7fc020 cp_parser_assignment_expression ../../gcc-source-trunk/gcc/cp/parser.c:9519 0x7fc8ca cp_parser_expression ../../gcc-source-trunk/gcc/cp/parser.c:9688 0x8001a9 cp_parser_expression_statement ../../gcc-source-trunk/gcc/cp/parser.c:11205 0x80b895 cp_parser_statement ../../gcc-source-trunk/gcc/cp/parser.c:11021 0x80cb9f cp_parser_statement_seq_opt ../../gcc-source-trunk/gcc/cp/parser.c:11348 0x80ccaf cp_parser_compound_statement ../../gcc-source-trunk/gcc/cp/parser.c:11302 0x825490 cp_parser_function_body ../../gcc-source-trunk/gcc/cp/parser.c:21840 0x825490 cp_parser_ctor_initializer_opt_and_function_body ../../gcc-source-trunk/gcc/cp/parser.c:21875 0x825edc cp_parser_function_definition_after_declarator ../../gcc-source-trunk/gcc/cp/parser.c:26766 0x82b1cc cp_parser_late_parsing_for_member ../../gcc-source-trunk/gcc/cp/parser.c:27647 0x805c5e cp_parser_class_specifier_1 ../../gcc-source-trunk/gcc/cp/parser.c:22729 0x807549 cp_parser_class_specifier ../../gcc-source-trunk/gcc/cp/parser.c:22755 0x807549 cp_parser_type_specifier ../../gcc-source-trunk/gcc/cp/parser.c:16819 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. $ -------------------------------- void *operator new (long unsigned int, void *p) { return p; } struct A {}; struct B { void f () { new (&d[-1]) A (); } int d[2]; };