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

            Bug ID: 127173
           Summary: [c++] Segfault with fno-enforce-eh-specs on a function
                    with noexcept and a contract
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: saaadhu at gcc dot gnu.org
  Target Milestone: ---

The following code causes a segfault/ICE on both master and 16.2
(https://godbolt.org/z/ohsTYhW1s)

$ cat ex.C
void f(int x) noexcept pre(x>1)
{
}

$ mips-unknown-elf-g++ -std=c++26 -fno-enforce-eh-specs ex.C
ex.C: In function 'void f(int)':
ex.C:3:1: internal compiler error: Segmentation fault
    3 | }
      | ^
0x363d9d9 internal_error(char const*, ...)
        /opt/developer/oss/src/gcc/gcc/diagnostic-global-context.cc:787
0x1ee3e65 crash_signal
        /opt/developer/oss/src/gcc/gcc/toplev.cc:325
0x11314db maybe_apply_function_contracts(tree_node*)
        /opt/developer/oss/src/gcc/gcc/cp/contracts.cc:1370
0x11ab5c8 finish_function(bool)
        /opt/developer/oss/src/gcc/gcc/cp/decl.cc:20736
0x1363474 cp_parser_function_definition_after_declarator
        /opt/developer/oss/src/gcc/gcc/cp/parser.cc:36353
0x136324f cp_parser_function_definition_from_specifiers_and_declarator
        /opt/developer/oss/src/gcc/gcc/cp/parser.cc:36265
0x134ca44 cp_parser_init_declarator
        /opt/developer/oss/src/gcc/gcc/cp/parser.cc:26179
0x133af38 cp_parser_simple_declaration
        /opt/developer/oss/src/gcc/gcc/cp/parser.cc:18196
0x133aaa4 cp_parser_block_declaration
        /opt/developer/oss/src/gcc/gcc/cp/parser.cc:18015
0x133a4d4 cp_parser_declaration
        /opt/developer/oss/src/gcc/gcc/cp/parser.cc:17816
0x133a5b1 cp_parser_toplevel_declaration
        /opt/developer/oss/src/gcc/gcc/cp/parser.cc:17837
0x131a24b cp_parser_translation_unit
        /opt/developer/oss/src/gcc/gcc/cp/parser.cc:5599
0x13ac46f c_parse_file()
        /opt/developer/oss/src/gcc/gcc/cp/parser.cc:57896
0x1622a5f c_common_parse_file()
        /opt/developer/oss/src/gcc/gcc/c-family/c-opts.cc:1437
/opt/developer/install/libexec/gcc/mips-unknown-elf/17.0.0/cc1plus -quiet ex.C
-quiet -dumpdir a- -dumpbase ex.C -dumpbase-ext .C -std=c++26
-fno-enforce-eh-specs -o /tmp/ccQz49W4.s
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Reply via email to