public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [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
@ 2022-02-16 16:02 nickhuang99 at hotmail dot com
  2022-02-16 17:51 ` [Bug c++/104568] [10/11/12 Regression] ICE [c++20] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: nickhuang99 at hotmail dot com @ 2022-02-16 16:02 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-05-10 10:23 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 16:02 [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 nickhuang99 at hotmail dot com
2022-02-16 17:51 ` [Bug c++/104568] [10/11/12 Regression] ICE [c++20] " pinskia at gcc dot gnu.org
2022-02-16 17:53 ` pinskia at gcc dot gnu.org
2022-02-16 18:29 ` jakub at gcc dot gnu.org
2022-02-16 19:26 ` jakub at gcc dot gnu.org
2022-02-17 10:08 ` rguenth at gcc dot gnu.org
2022-02-17 15:09 ` jakub at gcc dot gnu.org
2022-03-18 18:02 ` cvs-commit at gcc dot gnu.org
2022-03-18 18:03 ` [Bug c++/104568] [10/11 " jakub at gcc dot gnu.org
2022-03-29  5:54 ` cvs-commit at gcc dot gnu.org
2022-03-30  8:16 ` [Bug c++/104568] [10 " jakub at gcc dot gnu.org
2022-05-10  8:25 ` cvs-commit at gcc dot gnu.org
2022-05-10 10:23 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).