https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120754
Bug ID: 120754
Summary: Segfault when trying to print error about catching
function type
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: blubban at gmail dot com
Target Milestone: ---
template<typename T>
void fn()
{
try {}
catch (T) {}
}
int main() { fn<int(int)>(); }
Expected: Print a proper error, something like the 'error: variable 'v' has
function type' I get if the variable is named in the catch block.
Actual: Just says 'confused by earlier errors, bailing out' despite not
printing any earlier errors.
(Oddly enough, Clang and MSVC are fine with that input, both with and without
variable name. I think they're wrong.)
With Godbolt's GCC-assertions edition https://godbolt.org/z/16fcYxT7e,
<source>: In instantiation of 'void fn() [with T = int(int)]':
<source>:7:26: required from here
7 | int main() { fn<int(int)>(); }
| ~~~~~~~~~~~~^~
Segmentation fault
5 | catch (T) {}
| ^
0x31c6425 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x31dd3f6 internal_error(char const*, ...)
???:0
0x3200bd3 pretty_printer::format(text_info&)
???:0
0x31c60af diagnostic_context::report_diagnostic(diagnostic_info*)
???:0
0x31c6425 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x31dca66 error(char const*, ...)
???:0
0x1299534 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x128c1cd instantiate_decl(tree_node*, bool, bool)
???:0
0x12c67cb instantiate_pending_templates(int)
???:0
0x114b710 c_parse_final_cleanups()
???:0
0x13c40d8 c_common_parse_file()
???: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.