public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/86974] Support Clang's require_constant_initialization attribute
       [not found] <bug-86974-4@http.gcc.gnu.org/bugzilla/>
@ 2022-03-16 16:32 ` marc.mutz at hotmail dot com
  2022-03-16 16:40 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: marc.mutz at hotmail dot com @ 2022-03-16 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

Marc Mutz <marc.mutz at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marc.mutz at hotmail dot com

--- Comment #5 from Marc Mutz <marc.mutz at hotmail dot com> ---
Not really superseded by constinit. constinit is only available in C++20. If
you want constinit, you get all of C++20. OTOH,
[[clang::require_constant_initialization]] works all the way back to C++11.

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

* [Bug c++/86974] Support Clang's require_constant_initialization attribute
       [not found] <bug-86974-4@http.gcc.gnu.org/bugzilla/>
  2022-03-16 16:32 ` [Bug c++/86974] Support Clang's require_constant_initialization attribute marc.mutz at hotmail dot com
@ 2022-03-16 16:40 ` jakub at gcc dot gnu.org
  2022-03-16 16:41 ` marc.mutz at hotmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-16 16:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC does support __constinit as an alternate spelling of constinit, and while
constinit is only available in -std=c++20 and later, __constinit is available
even in C++11.

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

* [Bug c++/86974] Support Clang's require_constant_initialization attribute
       [not found] <bug-86974-4@http.gcc.gnu.org/bugzilla/>
  2022-03-16 16:32 ` [Bug c++/86974] Support Clang's require_constant_initialization attribute marc.mutz at hotmail dot com
  2022-03-16 16:40 ` jakub at gcc dot gnu.org
@ 2022-03-16 16:41 ` marc.mutz at hotmail dot com
  2022-03-16 17:01 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: marc.mutz at hotmail dot com @ 2022-03-16 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Marc Mutz <marc.mutz at hotmail dot com> ---
Fantastic! Thanks for the tip!

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

* [Bug c++/86974] Support Clang's require_constant_initialization attribute
       [not found] <bug-86974-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2022-03-16 16:41 ` marc.mutz at hotmail dot com
@ 2022-03-16 17:01 ` redi at gcc dot gnu.org
  2022-03-16 17:02 ` redi at gcc dot gnu.org
  2022-03-16 17:04 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-16 17:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
libstdc++ sources do this:

#if __has_cpp_attribute(clang::require_constant_initialization)
#  define __constinit [[clang::require_constant_initialization]]
#endif

An alternative that doesn't use reserved names and so is suitable for user code
would be:

#if __cpp_constinit
# define CONSTINIT constinit
#if __has_cpp_attribute(clang::require_constant_initialization)
# define CONSTINIT [[clang::require_constant_initialization]]
#elif __GNUC__ >= 10
# define CONSTINIT __constinit
#else
# define CONSTINIT
#endif

And then:

CONSTINIT S2 objx;

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

* [Bug c++/86974] Support Clang's require_constant_initialization attribute
       [not found] <bug-86974-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2022-03-16 17:01 ` redi at gcc dot gnu.org
@ 2022-03-16 17:02 ` redi at gcc dot gnu.org
  2022-03-16 17:04 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-16 17:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Oops, the second #if should be #elif

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

* [Bug c++/86974] Support Clang's require_constant_initialization attribute
       [not found] <bug-86974-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2022-03-16 17:02 ` redi at gcc dot gnu.org
@ 2022-03-16 17:04 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-16 17:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
One can't take __has_cpp_attribute support for granted, so perhaps that needs
to be wrapped inside ifdef.

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

end of thread, other threads:[~2022-03-16 17:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-86974-4@http.gcc.gnu.org/bugzilla/>
2022-03-16 16:32 ` [Bug c++/86974] Support Clang's require_constant_initialization attribute marc.mutz at hotmail dot com
2022-03-16 16:40 ` jakub at gcc dot gnu.org
2022-03-16 16:41 ` marc.mutz at hotmail dot com
2022-03-16 17:01 ` redi at gcc dot gnu.org
2022-03-16 17:02 ` redi at gcc dot gnu.org
2022-03-16 17:04 ` jakub 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).