[Bug c++/111173] G++ allows constinit functions

2023-08-30 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=73

Marek Polacek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #4 from Marek Polacek  ---
Fixed.

[Bug c++/111173] G++ allows constinit functions

2023-08-30 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=73

--- Comment #3 from CVS Commits  ---
The trunk branch has been updated by Marek Polacek :

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

commit r14-3576-gc121afc3b6c96a1f229ba0c4a4de6bd4b6be9a53
Author: Marek Polacek 
Date:   Tue Aug 29 13:16:41 2023 -0400

c++: disallow constinit on functions [PR73]

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

and while we detect

  constinit int fn();

we weren't detecting

  using F = int();
  constinit F f;

PR c++/73

gcc/cp/ChangeLog:

* decl.cc (grokdeclarator): Disallow constinit on functions.

gcc/testsuite/ChangeLog:

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

[Bug c++/111173] G++ allows constinit functions

2023-08-28 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=73

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org
 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

[Bug c++/111173] G++ allows constinit functions

2023-08-27 Thread janschultke at googlemail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=73

--- Comment #2 from Jan Schultke  ---
I think the problem is that GCC treats "constinit" exactly like "const" for the
purpose of diagnostics. In https://eel.is/c++draft/dcl.fct#11, it is said that
const applied to functions is ignored.

GCC produces error messages like:
> :1:1: error: 'constinit' on function return type is not allowed
> 1 | constinit void foo();
>   | ^

This does not make any sense; "constinit" wouldn't apply to the function return
type in the first place, but to the declarator-id. See
https://eel.is/c++draft/dcl.meaning.general#4

[Bug c++/111173] G++ allows constinit functions

2023-08-27 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=73

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2023-08-27
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Keywords||accepts-invalid

--- Comment #1 from Andrew Pinski  ---
Confirmed.