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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <[email protected]>:

https://gcc.gnu.org/g:54480d16b6cfdea3f0c45c7c97d937d99e59a1cd

commit r16-5725-g54480d16b6cfdea3f0c45c7c97d937d99e59a1cd
Author: Jakub Jelinek <[email protected]>
Date:   Sat Nov 29 17:37:58 2025 +0100

    c++: Limit P2795R5 handling of jumps across vacuous inits to
!processing_template_decl [PR122758]

    The extra handling of jumps across vacuous inits for -std=c++26
    or -ftrivial-auto-var-init={zero,pattern} added for P2795R5 is undesirable
    when processing_template_decl, because it creates labels without DECL_NAME
    and GOTO_EXPRs to those and those can't be tsubsted.
    I was afraid the pop_labels and check_goto_1 and check_previous_goto_1
    handling might not happen again during instantiation, but clearly it does
    happen fully (and has to, because whether some declaration has vacuous
    initialization or not can't be decided in some cases when parsing the
    template, if dependent types are involved).

    So, this patch just restricts the P2795R5 PR114457 r16-4212 changes
    to !processing_template_decl and adds 2 copies of the erroneous2.C
testcase,
    one changing the function into a function template where nothing is
    dependent and another one where most of the declarations are dependent.

    2025-11-29  Jakub Jelinek  <[email protected]>

            PR c++/122758
            * decl.cc (pop_labels): Don't call adjust_backward_gotos if
            processing_template_decl.
            (decl_instrument_init_bypass_p): Always return false if
            processing_template_decl.
            (check_goto_1): Don't push anything to direct_goto vector
            if processing_template_decl.

            * g++.dg/cpp26/erroneous5.C: New test.
            * g++.dg/cpp26/erroneous6.C: New test.

Reply via email to