Issue 181361
Summary Includes of stddef.h after the first include do not respect include guards with c++23
Labels new issue
Assignees
Reporter compudj
    Includes of stddef.h after the first include should have no effect due to the include guard, but the stddef.h builtin header provided with Clang Modules don't seem to abide by this.

With the following input code:

a.cpp:

```
#include <stddef.h>
static char a = {
#include <stddef.h>
    0
};
int main { return 0; }
```

This works:
clang -std=c++17 a.cpp

It works with clang 18.1.0, but breaks with clang 17.1.0, and starting from clang 19.1.0 onward:
clang -std=c++23 a.cpp

```
    Output of x86-64 clang 21.1.0 (Compiler #1)

In file included from <source>:4:
In file included from /cefs/d2/d2e6ebb9fe16525f6e7eb0c3_consolidated/compilers_c++_clang_21.1.0/lib/clang/21/include/stddef.h:88:
/cefs/d2/d2e6ebb9fe16525f6e7eb0c3_consolidated/compilers_c++_clang_21.1.0/lib/clang/21/include/__stddef_ptrdiff_t.h:18:1: error: expected _expression_
   18 | typedef __PTRDIFF_TYPE__ ptrdiff_t;
 | ^
1 error generated.
ASM generation compiler returned: 1
In file included from <source>:4:
In file included from /cefs/d2/d2e6ebb9fe16525f6e7eb0c3_consolidated/compilers_c++_clang_21.1.0/lib/clang/21/include/stddef.h:88:
/cefs/d2/d2e6ebb9fe16525f6e7eb0c3_consolidated/compilers_c++_clang_21.1.0/lib/clang/21/include/__stddef_ptrdiff_t.h:18:1: error: expected _expression_
   18 | typedef __PTRDIFF_TYPE__ ptrdiff_t;
 | ^
1 error generated.
Execution build compiler returned: 1
Build failed
```

This was reported on the LTTng-UST bug tracker: https://bugs.lttng.org/issues/1435
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to