https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120685
Bug ID: 120685
Summary: GCC Crashes After C++23 auto(t) Warning Instead of
Graceful Error
Product: gcc
Version: 15.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: qingren2hxb at gmail dot com
Target Milestone: ---
Created attachment 61652
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61652&action=edit
decltype auto bug report
Input:
========================
#include <utility>
template <typename T, typename U>
auto f(T t, U u) -> decltype(auto(t), auto(u))
{
return std::make_pair(t, u);
}
int main()
{
auto result = f(42, 3.14f);
return 0;
}
========================
Output:
========================
$ g++ -
decltype_auto.cpp:3:30: warning: 'auto(x)' only available with '-std=c++23' or
'-std=gnu++23' [-Wc++23-extensions]
3 | auto f(T t, U u) -> decltype(auto(t), auto(u)) {
| ^~~~~~~
decltype_auto.cpp:3:30: warning: 'auto(x)' only available with '-std=c++23' or
'-std=gnu++23' [-Wc++23-extensions]
decltype_auto.cpp:3:39: warning: 'auto(x)' only available with '-std=c++23' or
'-std=gnu++23' [-Wc++23-extensions]
3 | auto f(T t, U u) -> decltype(auto(t), auto(u)) {
| ^~~~~~~
decltype_auto.cpp: In substitution of 'template<class T, class U> decltype
(((auto)(t), (auto)(u))) f(T, U) [with T = int; U = float]':
decltype_auto.cpp:8:18: required from here
8 | auto result = f(42, 3.14f);
| ~^~~~~~~~~~~
decltype_auto.cpp:3:30: warning: 'auto(x)' only available with '-std=c++23' or
'-std=gnu++23' [-Wc++23-extensions]
3 | auto f(T t, U u) -> decltype(auto(t), auto(u)) {
| ^~~~~~~
decltype_auto.cpp:3:39: warning: 'auto(x)' only available with '-std=c++23' or
'-std=gnu++23' [-Wc++23-extensions]
3 | auto f(T t, U u) -> decltype(auto(t), auto(u)) {
| ^~~~~~~
internal compiler error: error reporting routines re-entered.
0x232cbce diagnostic_context::report_diagnostic(diagnostic_info*)
???:0
0x232cd05 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x233c100 pedwarn(unsigned long, diagnostic_option_id, char const*, ...)
???:0
0xa6efb1 build_functional_cast(unsigned long, tree_node*, tree_node*, int)
???:0
0x9f985b tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x2349228 pretty_printer::format(text_info&)
???:0
0x234b55e pp_verbatim(pretty_printer*, char const*, ...)
???:0
0x233ac00 diagnostic_text_output_format::on_report_diagnostic(diagnostic_info
const&, diagnostic_t)
???:0
0x232c88a diagnostic_context::report_diagnostic(diagnostic_info*)
???:0
0x232cd05 diagnostic_context::diagnostic_impl(rich_location*,
diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag
(*) [1], diagnostic_t)
???:0
0x233c9dd error_at(rich_location*, char const*, ...)
???:0
0xa691c3 check_return_expr(tree_node*, bool*, bool*)
???:0
0xa24252 finish_return_stmt(tree_node*)
???:0
0x9ed79d instantiate_decl(tree_node*, bool, bool)
???:0
0xa150f3 instantiate_pending_templates(int)
???:0
0x8e1575 c_parse_final_cleanups()
???:0
0xadc4d0 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.
========================
Version: gcc-15.1.0
The compiler properly warns about auto(t) being a C++23 feature, but then
crashes with an ICE rather than handling the error gracefully.