On 10/23/24 2:41 PM, Jonathan Wakely wrote:
On Wed, 23 Oct 2024 at 16:02, Jason Merrill <ja...@redhat.com> wrote:

On 10/23/24 10:39 AM, Jonathan Wakely wrote:
The __alignas_is_defined macro has been required by C++ since C++11, and
C++ Library DR 4036 clarified that __alignof_is_defined should be
defined too.

The macros alignas and alignof should not be defined, as they're
keywords in C++.

Technically it's implementation-defined whether __STDC_VERSION__ is
defined by a C++ compiler, but G++ does not define it. Adjusting the
first #if this way works as intended: A C23 compiler will not enter the
outer if-group and so will not define any of the macros, a C17 compiler
will enter both if-groups and so define all the macros, and a C++
compiler will enter the outer if-group but not the inner if-group.

gcc/ChangeLog:

       * ginclude/stdalign.h (__alignas_is_defined): Define for C++.
       (__alignof_is_defined): Likewise.

Do we want to note somehow that these macros are deprecated since C++17?

The <cstdalign> header is deprecated in C++17, but the macros aren't
if you get them via <stdalign.h>. They were deprecated for C++23 by my
NB comment https://cplusplus.github.io/LWG/issue3827

Would you like it to be noted in the commit message, or in the header
itself, something like this?

--- a/gcc/ginclude/stdalign.h
+++ b/gcc/ginclude/stdalign.h
@@ -33,6 +33,7 @@ see the files COPYING3 and COPYING.RUNTIME
respectively.  If not, see
#define alignof _Alignof
#endif

+/* These are defined for C++, but deprecated in C++23.  */
#define __alignas_is_defined 1
#define __alignof_is_defined 1

Sure, OK with that comment.

Jason

Reply via email to