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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Marek Polacek
<mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:90824f6c57e1ac7b94c558b4c99721b412df75ef

commit r11-10381-g90824f6c57e1ac7b94c558b4c99721b412df75ef
Author: Marek Polacek <pola...@redhat.com>
Date:   Thu Nov 17 11:59:29 2022 -0500

    c++: constinit on pointer to function [PR104066]

    [dcl.constinit]: "The constinit specifier shall be applied only to
    a declaration of a variable with static or thread storage duration."

    Thus, this ought to be OK:

      constinit void (*p)() = nullptr;

    but the error message I introduced when implementing constinit was
    not looking at funcdecl_p, so the code above was rejected.

    Fixed thus.  I'm checking constinit_p first because I think that's
    far more likely to be false than funcdecl_p.

            PR c++/104066

    gcc/cp/ChangeLog:

            * decl.c (grokdeclarator): Check funcdecl_p before complaining
            about constinit.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/constinit18.C: New test.

    (cherry picked from commit 7b3b2f50953c5143d4b14b59d322d8a793f411dd)

Reply via email to