[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 gcc-bugzilla@gcc.gnu.org
Mon Jan 17 12:08:06 GMT 2022


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


More information about the Gcc-bugs mailing list