From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 348773857C59; Wed, 16 Feb 2022 16:02:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 348773857C59 From: "nickhuang99 at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104568] New: ICE [regression c++20] caused by option "-std=c++20 -Wall" when operand of operator new has size equal to 0 Date: Wed, 16 Feb 2022 16:02:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nickhuang99 at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Feb 2022 16:02:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104568 Bug ID: 104568 Summary: ICE [regression c++20] caused by option "-std=3Dc++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=3Dc++20 -Wall"= which proves it to be a regression of c++20.=20 The root cause is very simple that "std::default_delete" has a static_asser= t 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 cau= se without crash. However, "-std=3Dc++20 -Wall" option issues very confusing e= rror message "Floating point exception" and crashes. #include using namespace std; typedef int Ary0[0]; int main(){ unique_ptr ptr; ptr.reset(new Ary0[0]); return 0; } tests/unique.cpp: In function =E2=80=98int main()=E2=80=99: 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*) /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*, 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 for instructions.=