[Bug c++/126483] [13/14/15/16/17 Regression] Wrong active union member in constant evaluation of variable template initializers since r13-6422

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126483

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Patrick Palka
<[email protected]>:

https://gcc.gnu.org/g:7ed28af4fcad61780d5f4b38b5a99fdfcc2e6b03

commit r16-9537-g7ed28af4fcad61780d5f4b38b5a99fdfcc2e6b03
Author: Patrick Palka <[email protected]>
Date:   Fri Aug 14 15:53:10 2026 -0400

    c++: testsuite: Add some opt/is_constant_evaluated3.C variants

    r13-6422 added opt/is_constant_evaluated3.C to verify that we constant
    fold copy-init such as a1.  (Later, r14-6506 enabled constant folding of
    the a2-a5 inits.)  r13-6422 turns out to trigger a latent bug and causes
    PR c++/126483, premature folding of is_constant_evaluated in copy-init
    inside a lambda scope.

    This patch adds a couple extra variants of this test, one where the
    containing function is constexpr (3a) and one where it's a lambda (3b).

    The new 3a.C demonstrates however that we still don't constant fold a1's
    copy-init when inside a constexpr function scope.  3b.C demonstrates that
    we do fold it when inside a (maybe-constexpr) lambda scope.

    gcc/testsuite/ChangeLog:

            * g++.dg/opt/is_constant_evaluated3a.C: New test.
            * g++.dg/opt/is_constant_evaluated3b.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>
    (cherry picked from commit 9b0341a7a6a38912e667982003bcbfebdfb86335)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.