public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pobrn at protonmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/115219] New: ICE on conditionally noexcept class operator delete
Date: Fri, 24 May 2024 22:51:19 +0000	[thread overview]
Message-ID: <bug-115219-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115219

            Bug ID: 115219
           Summary: ICE on conditionally noexcept class operator delete
           Product: gcc
           Version: 14.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pobrn at protonmail dot com
  Target Milestone: ---

Consider the following piece of C++ code:

```
#include <new>
#include <type_traits>

template<typename Derived>
struct B {
    static void *
    operator new(std::size_t s, std::size_t)
    { return ::operator new(s); }

    static void
    operator delete(void *)
    noexcept(std::is_nothrow_destructible_v<Derived>)
    { }
};

struct A : B<A> { };

void test() {
    new (42) A();
}
```

gcc 14.1.1 and trunk (on CE) trigger the following ICE (
https://gcc.godbolt.org/z/z7av1Mf3Y ):

```
<source>: In function 'void test()':
<source>:19:16: internal compiler error: in type_throw_all_p, at
cp/except.cc:1234
   19 |     new (42) A();
      |                ^
0x268e9ac internal_error(char const*, ...)
        ???:0
0xa5b247 fancy_abort(char const*, int, char const*)
        ???:0
0xb08bb3 fnptr_conv_p(tree_node*, tree_node*)
        ???:0
0xaa0ae6 instantiate_type(tree_node*, tree_node*, int)
        ???:0
0xa75b7e build_op_delete_call(tree_code, tree_node*, tree_node*, bool,
tree_node*, tree_node*, int)
        ???:0
0xb82ab0 build_new(unsigned int, vec<tree_node*, va_gc, vl_embed>**,
tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, int, int)
        ???:0
0xc63d8a c_parse_file()
        ???:0
0xdb95b9 c_common_parse_file()
        ???:0
```

Removing the conditional noexcept specification makes the ICE go away.

Here is a more detailed stack trace from the arch linux build of gcc (about
14.1.1):

```
Breakpoint 1, internal_error (gmsgid=gmsgid@entry=0x2b4b860 "in %s, at %s:%d")
at /usr/src/debug/gcc/gcc/gcc/diagnostic.cc:2227
2227    {
(gdb) bt
#0  internal_error (gmsgid=gmsgid@entry=0x2b4b860 "in %s, at %s:%d") at
/usr/src/debug/gcc/gcc/gcc/diagnostic.cc:2227
#1  0x0000000000703e88 in fancy_abort (file=0x2b5c798
"/usr/src/debug/gcc/gcc/gcc/cp/except.cc", line=1234, function=0x2aa87dc
"type_throw_all_p") at /usr/src/debug/gcc/gcc/gcc/diagnostic.cc:2353
#2  0x00000000006b97f2 in type_throw_all_p (type=<optimized out>) at
/usr/src/debug/gcc/gcc/gcc/cp/except.cc:1231
#3  type_throw_all_p (type=<optimized out>) at
/usr/src/debug/gcc/gcc/gcc/cp/except.cc:1231
#4  noexcept_conv_p (to=0x7ffff6c24498, from=0x7ffff6a15930) at
/usr/src/debug/gcc/gcc/gcc/cp/cvt.cc:2130
#5  fnptr_conv_p (to=<optimized out>, from=<optimized out>) at
/usr/src/debug/gcc/gcc/gcc/cp/cvt.cc:2157
#6  0x000000000072a772 in instantiate_type (lhstype=0x7ffff6c24498,
rhs=0x7ffff6a10690, complain=0) at /usr/src/debug/gcc/gcc/gcc/cp/class.cc:9085
#7  0x000000000072cede in build_op_delete_call (code=DELETE_EXPR,
addr=0x7ffff6a1e1e0, size=0x7ffff6e212d0, global_p=<optimized out>,
placement=0x7ffff6a1b340, alloc_fn=0x7ffff6de9700, complain=3)
    at /usr/src/debug/gcc/gcc/gcc/cp/call.cc:7893
#8  0x0000000000804299 in build_new_1
(placement=placement@entry=0x7fffffffcd78, type=<optimized out>,
nelts=<optimized out>, nelts@entry=0x0, init=init@entry=0x7fffffffcd70, 
    globally_qualified_p=globally_qualified_p@entry=false,
complain=complain@entry=3) at /usr/src/debug/gcc/gcc/gcc/cp/init.cc:3784
#9  0x00000000008055ca in build_new (loc=64384747, placement=0x7fffffffcd78,
type=<optimized out>, nelts=0x0, init=0x7fffffffcd70, use_global_new=0,
complain=3) at /usr/src/debug/gcc/gcc/gcc/cp/init.cc:4054
#10 0x0000000000867ab7 in cp_parser_new_expression
(parser=parser@entry=0x7ffff6fb4dc8) at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:9659
#11 0x000000000086258b in cp_parser_unary_expression (parser=0x7ffff6fb4dc8,
pidk=<optimized out>, address_p=<optimized out>, cast_p=<optimized out>,
decltype_p=<optimized out>)
    at /usr/src/debug/gcc/gcc/gcc/cp/parser.cc:9245
#12 0x0000000000864664 in cp_parser_binary_expression
(parser=parser@entry=0x7ffff6fb4dc8, cast_p=cast_p@entry=false,
no_toplevel_fold_p=no_toplevel_fold_p@entry=false,
decltype_p=decltype_p@entry=false, 
    prec=prec@entry=PREC_NOT_OPERATOR, pidk=pidk@entry=0x0) at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:10393
#13 0x00000000008653bd in cp_parser_assignment_expression
(parser=parser@entry=0x7ffff6fb4dc8, pidk=pidk@entry=0x0,
cast_p=cast_p@entry=false, decltype_p=decltype_p@entry=false)
    at /usr/src/debug/gcc/gcc/gcc/cp/parser.cc:10737
#14 0x0000000000865994 in cp_parser_expression
(parser=parser@entry=0x7ffff6fb4dc8, pidk=pidk@entry=0x0,
cast_p=cast_p@entry=false, decltype_p=decltype_p@entry=false,
warn_comma_p=warn_comma_p@entry=false)
    at /usr/src/debug/gcc/gcc/gcc/cp/parser.cc:10903
#15 0x000000000086622e in cp_parser_expression_statement
(parser=0x7ffff6fb4dc8, in_statement_expr=0x0) at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:13166
#16 0x0000000000876d31 in cp_parser_statement
(parser=parser@entry=0x7ffff6fb4dc8,
in_statement_expr=in_statement_expr@entry=0x0,
in_compound=in_compound@entry=true, if_p=if_p@entry=0x0, chain=chain@entry=0x0, 
    loc_after_labels=loc_after_labels@entry=0x0) at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:12947
#17 0x0000000000877b0c in cp_parser_statement_seq_opt
(parser=parser@entry=0x7ffff6fb4dc8,
in_statement_expr=in_statement_expr@entry=0x0) at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:13418
#18 0x0000000000877d40 in cp_parser_compound_statement (parser=0x7ffff6fb4dc8,
in_statement_expr=0x0, bcs_flags=<optimized out>, function_body=true) at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:13272
#19 0x0000000000883042 in cp_parser_function_body (parser=0x7ffff6fb4dc8,
in_function_try_block=false) at /usr/src/debug/gcc/gcc/gcc/cp/parser.cc:25987
#20 cp_parser_ctor_initializer_opt_and_function_body (parser=0x7ffff6fb4dc8,
in_function_try_block=false) at /usr/src/debug/gcc/gcc/gcc/cp/parser.cc:26038
#21 0x00000000008a8d2b in cp_parser_function_definition_after_declarator
(parser=parser@entry=0x7ffff6fb4dc8, inline_p=inline_p@entry=false) at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:32729
#22 0x00000000008a9e50 in
cp_parser_function_definition_from_specifiers_and_declarator
(parser=0x7ffff6fb4dc8, decl_specifiers=<optimized out>, attributes=0x0,
declarator=0x31fb9a0)
    at /usr/src/debug/gcc/gcc/gcc/cp/parser.cc:32647
#23 cp_parser_init_declarator (parser=0x7ffff6fb4dc8, flags=<optimized out>,
decl_specifiers=<optimized out>, checks=0x0,
function_definition_allowed_p=<optimized out>, member_p=false, 
    declares_class_or_enum=0, function_definition_p=0x7fffffffd6f8,
maybe_range_for_decl=0x0, init_loc=0x7fffffffd6f0, auto_result=0x7fffffffd700)
at /usr/src/debug/gcc/gcc/gcc/cp/parser.cc:23366
#24 0x0000000000873c72 in cp_parser_simple_declaration (parser=0x7ffff6fb4dc8,
function_definition_allowed_p=<optimized out>, maybe_range_for_decl=0x0) at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:15900
#25 0x0000000000878ccd in cp_parser_declaration (parser=0x7ffff6fb4dc8,
prefix_attrs=0x0) at /usr/src/debug/gcc/gcc/gcc/cp/parser.cc:15573
#26 0x0000000000879734 in cp_parser_toplevel_declaration
(parser=0x7ffff6fb4dc8) at /usr/src/debug/gcc/gcc/gcc/cp/parser.cc:15594
#27 cp_parser_translation_unit (parser=0x7ffff6fb4dc8) at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:5279
#28 0x00000000009c4ed1 in c_parse_file () at
/usr/src/debug/gcc/gcc/gcc/cp/parser.cc:51269
#29 c_common_parse_file () at
/usr/src/debug/gcc/gcc/gcc/c-family/c-opts.cc:1311
#30 0x0000000000fa020f in compile_file () at
/usr/src/debug/gcc/gcc/gcc/toplev.cc:449
#31 0x000000000070d122 in do_compile () at
/usr/src/debug/gcc/gcc/gcc/toplev.cc:2154
#32 toplev::main (this=<optimized out>, argc=<optimized out>, argv=<optimized
out>) at /usr/src/debug/gcc/gcc/gcc/toplev.cc:2310
#33 0x000000000070da36 in main (argc=<optimized out>, argv=<optimized out>) at
/usr/src/debug/gcc/gcc/gcc/main.cc:39
```

             reply	other threads:[~2024-05-24 22:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-24 22:51 pobrn at protonmail dot com [this message]
2024-05-24 23:04 ` [Bug c++/115219] [c++17+] ICE on depdendent " pinskia at gcc dot gnu.org
2024-05-24 23:04 ` pinskia at gcc dot gnu.org
2024-05-24 23:05 ` [Bug c++/115219] [11/12/13/14/15 Regression] " pinskia at gcc dot gnu.org
2024-05-24 23:40 ` pobrn at protonmail dot com
2024-05-24 23:48 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-115219-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).