public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
@ 2022-01-17 12:08 safinaskar at mail dot ru
  2022-01-20  5:26 ` [Bug c++/104066] "extern constinit long (* const syscall_reexported) (long, ...); " " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: safinaskar at mail dot ru @ 2022-01-17 12:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104066
           Summary: "extern constinit long (* const syscall_reexported)
                    (long, ...);" doesn't compile: gcc thinks "constinit"
                    applies to return value, not to function pointer
                    itself
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: safinaskar at mail dot ru
  Target Milestone: ---

Consider this code:

extern constinit long (* const syscall_reexported) (long, ...);

(Godbolt: https://godbolt.org/z/de7W55rTo )

clang 13 happily compiles this code. gcc 11.2 rejects this code with message:

<source>:1:8: error: 'constinit' on function return type is not allowed
    1 | extern constinit long (* const syscall_reexported) (long, ...);
      |        ^~~~~~~~~

I. e. gcc thinks that "constinit" applies to return value, not to function
pointer itself

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/104066] "extern constinit long (* const syscall_reexported) (long, ...); " doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
  2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
@ 2022-01-20  5:26 ` pinskia at gcc dot gnu.org
  2022-11-15 21:26 ` [Bug c++/104066] "extern constinit long (* const syscall_reexported) (long, ...);" " pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-20  5:26 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-01-20
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/104066] "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
  2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
  2022-01-20  5:26 ` [Bug c++/104066] "extern constinit long (* const syscall_reexported) (long, ...); " " pinskia at gcc dot gnu.org
@ 2022-11-15 21:26 ` pinskia at gcc dot gnu.org
  2022-11-15 21:38 ` [Bug c++/104066] "constinit extern long (*const f) ();" " mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-15 21:26 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |redi at gcc dot gnu.org

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 107710 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/104066] "constinit extern long (*const f) ();" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
  2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
  2022-01-20  5:26 ` [Bug c++/104066] "extern constinit long (* const syscall_reexported) (long, ...); " " pinskia at gcc dot gnu.org
  2022-11-15 21:26 ` [Bug c++/104066] "extern constinit long (* const syscall_reexported) (long, ...);" " pinskia at gcc dot gnu.org
@ 2022-11-15 21:38 ` mpolacek at gcc dot gnu.org
  2022-11-18  0:17 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-11-15 21:38 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Ah, I suppose I should've checked funcdecl_p before giving the error.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/104066] "constinit extern long (*const f) ();" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
  2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
                   ` (2 preceding siblings ...)
  2022-11-15 21:38 ` [Bug c++/104066] "constinit extern long (*const f) ();" " mpolacek at gcc dot gnu.org
@ 2022-11-18  0:17 ` cvs-commit at gcc dot gnu.org
  2022-11-18  0:43 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-18  0:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

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

commit r13-4135-g7b3b2f50953c5143d4b14b59d322d8a793f411dd
Author: Marek Polacek <polacek@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.cc (grokdeclarator): Check funcdecl_p before complaining
            about constinit.

    gcc/testsuite/ChangeLog:

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/104066] "constinit extern long (*const f) ();" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
  2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
                   ` (3 preceding siblings ...)
  2022-11-18  0:17 ` cvs-commit at gcc dot gnu.org
@ 2022-11-18  0:43 ` cvs-commit at gcc dot gnu.org
  2022-11-18  0:45 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-18  0:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:14faa5f585f6025df1e04c8c8b34340ff5e4d494

commit r12-8916-g14faa5f585f6025df1e04c8c8b34340ff5e4d494
Author: Marek Polacek <polacek@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.cc (grokdeclarator): Check funcdecl_p before complaining
            about constinit.

    gcc/testsuite/ChangeLog:

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

    (cherry picked from commit 7b3b2f50953c5143d4b14b59d322d8a793f411dd)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/104066] "constinit extern long (*const f) ();" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
  2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
                   ` (4 preceding siblings ...)
  2022-11-18  0:43 ` cvs-commit at gcc dot gnu.org
@ 2022-11-18  0:45 ` cvs-commit at gcc dot gnu.org
  2022-11-18  0:47 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-18  0:45 UTC (permalink / raw)
  To: gcc-bugs

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
<mpolacek@gcc.gnu.org>:

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

commit r11-10381-g90824f6c57e1ac7b94c558b4c99721b412df75ef
Author: Marek Polacek <polacek@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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/104066] "constinit extern long (*const f) ();" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
  2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
                   ` (5 preceding siblings ...)
  2022-11-18  0:45 ` cvs-commit at gcc dot gnu.org
@ 2022-11-18  0:47 ` cvs-commit at gcc dot gnu.org
  2022-11-18  0:48 ` mpolacek at gcc dot gnu.org
  2022-11-18  0:53 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-11-18  0:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:b9b78b4de3c7dcc6868c4af831b2d213fda21b04

commit r10-11087-gb9b78b4de3c7dcc6868c4af831b2d213fda21b04
Author: Marek Polacek <polacek@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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/104066] "constinit extern long (*const f) ();" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
  2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
                   ` (6 preceding siblings ...)
  2022-11-18  0:47 ` cvs-commit at gcc dot gnu.org
@ 2022-11-18  0:48 ` mpolacek at gcc dot gnu.org
  2022-11-18  0:53 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-11-18  0:48 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed everywhere.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/104066] "constinit extern long (*const f) ();" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself
  2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
                   ` (7 preceding siblings ...)
  2022-11-18  0:48 ` mpolacek at gcc dot gnu.org
@ 2022-11-18  0:53 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-18  0:53 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.5
      Known to fail|                            |10.4.0, 11.3.0, 12.2.0
      Known to work|                            |10.4.1, 11.3.1, 12.2.1,
                   |                            |13.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-18  0:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17 12:08 [Bug c++/104066] New: "extern constinit long (* const syscall_reexported) (long, ...);" doesn't compile: gcc thinks "constinit" applies to return value, not to function pointer itself safinaskar at mail dot ru
2022-01-20  5:26 ` [Bug c++/104066] "extern constinit long (* const syscall_reexported) (long, ...); " " pinskia at gcc dot gnu.org
2022-11-15 21:26 ` [Bug c++/104066] "extern constinit long (* const syscall_reexported) (long, ...);" " pinskia at gcc dot gnu.org
2022-11-15 21:38 ` [Bug c++/104066] "constinit extern long (*const f) ();" " mpolacek at gcc dot gnu.org
2022-11-18  0:17 ` cvs-commit at gcc dot gnu.org
2022-11-18  0:43 ` cvs-commit at gcc dot gnu.org
2022-11-18  0:45 ` cvs-commit at gcc dot gnu.org
2022-11-18  0:47 ` cvs-commit at gcc dot gnu.org
2022-11-18  0:48 ` mpolacek at gcc dot gnu.org
2022-11-18  0:53 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).