[Bug c++/99901] [9/10 Regression] static const class var implemented with constexpr doesn't emit symbols in C++17 mode

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 20 21:35:16 GMT 2021


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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

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

commit r10-9847-g5b68416a940b32b739cdc033e018bab5161a721d
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 6 01:21:05 2021 -0400

    c++: C++17 constexpr static data member linkage [PR99901]

    C++17 makes constexpr static data members implicitly inline variables.  In
    C++14, a subsequent out-of-class declaration is the definition.  We want to
    continue emitting a symbol for such a declaration in C++17 mode, for ABI
    compatibility with C++14 code that wants to refer to it.

    Normally I'd distinguish in- and out-of-class declarations by looking at
    DECL_IN_AGGR_P, but we never set DECL_IN_AGGR_P on inline variables.  I
    think that's wrong, but don't want to mess with it so close to release.
    Conveniently, we already have a test for in-class declaration earlier in
the
    function.

    gcc/cp/ChangeLog:

            PR c++/99901
            * decl.c (cp_finish_decl): mark_needed an implicitly inline
            static data member with an out-of-class redeclaration.

    gcc/testsuite/ChangeLog:

            PR c++/99901
            * g++.dg/cpp1z/inline-var9.C: New test.


More information about the Gcc-bugs mailing list