https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104568
Bug ID: 104568 Summary: ICE [regression c++20] caused by option "-std=c++20 -Wall" when operand of operator new has size equal to 0 Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nickhuang99 at hotmail dot com Target Milestone: --- See the following program causes ICE with flag ONLY of "-std=c++20 -Wall" which proves it to be a regression of c++20. The root cause is very simple that "std::default_delete" has a static_assert to require element size pointed by pointer to be bigger than 0. A empty array of "int[0]" violates this assertion, all other flag gives the correct root cause without crash. However, "-std=c++20 -Wall" option issues very confusing error message "Floating point exception" and crashes. #include <memory> using namespace std; typedef int Ary0[0]; int main(){ unique_ptr<Ary0> ptr; ptr.reset(new Ary0[0]); return 0; } tests/unique.cpp: In function ‘int main()’: tests/unique.cpp:7:18: internal compiler error: Floating point exception 7 | ptr.reset(new Ary0[0]); | ~~~~~~~~~^~~~~~~~~~~~~ 0x1522a90 crash_signal /home/nick/Downloads/gcc-dev/gcc/gcc/toplev.cc:322 0xbd4829 build_new_constexpr_heap_type(tree_node*, tree_node*, tree_node*) /home/nick/Downloads/gcc-dev/gcc/gcc/cp/init.cc:2944 0xb2f837 cxx_eval_constant_expression /home/nick/Downloads/gcc-dev/gcc/gcc/cp/constexpr.cc:7262 0xb2f1cf cxx_eval_constant_expression /home/nick/Downloads/gcc-dev/gcc/gcc/cp/constexpr.cc:7147 0xb30dd1 cxx_eval_outermost_constant_expr /home/nick/Downloads/gcc-dev/gcc/gcc/cp/constexpr.cc:7700 0xb319d2 maybe_constant_value(tree_node*, tree_node*, bool) /home/nick/Downloads/gcc-dev/gcc/gcc/cp/constexpr.cc:7990 0xbcbd84 fold_for_warn(tree_node*) /home/nick/Downloads/gcc-dev/gcc/gcc/cp/expr.cc:416 0xddaed6 check_function_restrict /home/nick/Downloads/gcc-dev/gcc/gcc/c-family/c-common.cc:5704 0xddc1d9 check_function_arguments(unsigned int, tree_node const*, tree_node const*, int, tree_node**, vec<unsigned int, va_heap, vl_ptr>*) /home/nick/Downloads/gcc-dev/gcc/gcc/c-family/c-common.cc:6091 0xaf16fe build_over_call /home/nick/Downloads/gcc-dev/gcc/gcc/cp/call.cc:9662 0xaf5a03 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int) /home/nick/Downloads/gcc-dev/gcc/gcc/cp/call.cc:11146 0xc70cd6 cp_parser_postfix_expression /home/nick/Downloads/gcc-dev/gcc/gcc/cp/parser.cc:7844 0xc73625 cp_parser_unary_expression /home/nick/Downloads/gcc-dev/gcc/gcc/cp/parser.cc:9033 0xc74c64 cp_parser_cast_expression /home/nick/Downloads/gcc-dev/gcc/gcc/cp/parser.cc:9937 0xc74d82 cp_parser_binary_expression /home/nick/Downloads/gcc-dev/gcc/gcc/cp/parser.cc:10039 0xc75b61 cp_parser_assignment_expression /home/nick/Downloads/gcc-dev/gcc/gcc/cp/parser.cc:10343 0xc75ec3 cp_parser_expression /home/nick/Downloads/gcc-dev/gcc/gcc/cp/parser.cc:10513 0xc7adb5 cp_parser_expression_statement /home/nick/Downloads/gcc-dev/gcc/gcc/cp/parser.cc:12709 0xc7a795 cp_parser_statement /home/nick/Downloads/gcc-dev/gcc/gcc/cp/parser.cc:12505 0xc7b23c cp_parser_statement_seq_opt /home/nick/Downloads/gcc-dev/gcc/gcc/cp/parser.cc:12854 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.