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

            Bug ID: 107023
           Summary: [[gnu::stdcall]] Crashes the compiler, but
                    __attribute__((stdcall)) and __stdcall worrks
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bthomas at brave dot com
  Target Milestone: ---

```
#include <iostream>

template<typename T>
void call(T&& fn)
{    
    std::cout<<typeid(decltype(fn)).name()<<"\n";
}

[[gnu::stdcall]] bool test(void* eios) noexcept
{    
    return false;
}

int main() {
    call(test);
    return 0;
}
```

Example: https://godbolt.org/z/jhdqWbaT3

---

Will give the error with O3 (12.2, Flags: -O3 -std=c++20 -m32):

g++: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.
ASM generation compiler returned: 4
g++: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.
Execution build compiler returned: 4

---

Will give the error with O2 (12.2, Flags: -O2 -std=c++20 -m32):
g++: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.
ASM generation compiler returned: 4

cc1plus: out of memory allocating 18446744072522246992 bytes after a total of
2228224 bytes
Execution build compiler returned: 1

---

Will give the error with ANY flags (13.0 - Trunk, Flags: -O2 -std=c++20 -m32):

'
'
internal compiler error: error reporting routines re-entered.
0x2349dde internal_error(char const*, ...)
        ???:0
0x955fbc tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0x2368dec pp_format(pretty_printer*, text_info*)
        ???:0
0x236a1d5 pp_printf(pretty_printer*, char const*, ...)
        ???:0
0x2348785 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ???:0
0x2349dde internal_error(char const*, ...)
        ???:0
0x955fbc tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0x2368dec pp_format(pretty_printer*, text_info*)
        ???:0
0x236a1d5 pp_printf(pretty_printer*, char const*, ...)
        ???:0
0x2348785 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ???:0
0x2349dde internal_error(char const*, ...)
        ???:0
0x955fbc tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0xb992f8 lang_decl_name(tree_node*, int, bool)
        ???:0
0xb99346 lang_decl_dwarf_name(tree_node*, int, bool)
        ???:0
0xd8ab37 c_common_finalize_early_debug()
        ???:0
0xe78236 symbol_table::finalize_compilation_unit()
        ???:0
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.
ASM generation compiler returned: 1
'
'
internal compiler error: error reporting routines re-entered.
0x2349dde internal_error(char const*, ...)
        ???:0
0x955fbc tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0x2368dec pp_format(pretty_printer*, text_info*)
        ???:0
0x236a1d5 pp_printf(pretty_printer*, char const*, ...)
        ???:0
0x2348785 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ???:0
0x2349dde internal_error(char const*, ...)
        ???:0
0x955fbc tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0x2368dec pp_format(pretty_printer*, text_info*)
        ???:0
0x236a1d5 pp_printf(pretty_printer*, char const*, ...)
        ???:0
0x2348785 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ???:0
0x2349dde internal_error(char const*, ...)
        ???:0
0x955fbc tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0xb992f8 lang_decl_name(tree_node*, int, bool)
        ???:0
0xb99346 lang_decl_dwarf_name(tree_node*, int, bool)
        ???:0
0xd8ab37 c_common_finalize_early_debug()
        ???:0
0xe78236 symbol_table::finalize_compilation_unit()
        ???:0
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.
Execution build compiler returned: 1

----

It's worth noting that `__attribute__((stdcall))` and `__stdcall` works just
fine.

Reply via email to