Skip to content

No ::nullptr_t in header <stddef.h> #37564

@llvmbot

Description

@llvmbot
Bugzilla Link 38216
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@mclow,@zygoloid,@jwakely

Extended Description

clang++ rejects the following code:

#include <stddef.h>

::nullptr_t n;

"3|error: 'nullptr_t' in namespace '::' does not name a type"

This code is supposed to be accepted, because [depr.c.headers] p2 says:

"Every C header, each of which has a name of the form name.h, behaves as if each name placed in the standard library namespace by the corresponding cname header is placed within the global namespace scope."

Paolo Carlini has suggested to perform this change near to existing C++11-aware code in stddef.h:

#if (defined (STDC_VERSION) && STDC_VERSION >= 201112L)
|| (defined(__cplusplus) && __cplusplus >= 201103L)
#ifndef _GCC_MAX_ALIGN_T
#define _GCC_MAX_ALIGN_T
/* Type whose alignment is supported in every context and is at least
as great as that of any standard type not using alignment
specifiers. /
typedef struct {
long long __max_align_ll attribute((aligned(alignof(long long))));
long double __max_align_ld attribute((aligned(alignof(long double))));
} max_align_t;
#endif
#endif /
C11 or C++11. */

BTW, I tried g++. It accepts the above code sample.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++11clang:headersHeaders provided by Clang, e.g. for intrinsics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions