[Bug c++/120685] [13 Regression] GCC Crashes After C++23 auto(t) Warning Instead of Graceful Error

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Mar 22 05:20:00 GMT 2026


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

--- Comment #13 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:5c16b43641f639e8ceeef65dd5e2c3ef7db5ff89

commit r13-10203-g5c16b43641f639e8ceeef65dd5e2c3ef7db5ff89
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Feb 17 08:59:06 2026 +0100

    c++: Don't support auto{x} and auto(x) for C++ < 23 in SFINAE contexts
[PR120685]

    The following testcase ICEs in C++ 20 and older, because during
    diagnostics dump_template_bindings attempts to tsubst with tf_none
    something and we try to emit a pedwarn during that.
    While the pedwarn could be just guarded with if (complain & tf_warning),
    I thought we shouldn't support extensions for tf_none and should
    instead return error_mark_node.

    The following patch does that.

    This is a backport version which instead of not supporting it just
    doesn't emit the pedwarn in SFINAE contexts for C++ < 23 but still
    supports it.

    2026-02-17  Jakub Jelinek  <jakub@redhat.com>

            PR c++/120685
            * typeck2.cc (build_functional_cast_1): For C++23 auto(x)
            without tf_warning or tf_error return error_mark_node instead of
            emitting pedwarn and handling it.
            * semantics.cc (finish_compound_literal): Similarly for C++26
            auto{x}.

            * g++.dg/cpp23/auto-fncast19.C: New test.

    (cherry picked from commit f7efb7e62ac96c082ff72549d9b3789f5c955efe)


More information about the Gcc-bugs mailing list