[libcxx-commits] [libcxx] [libc++][modularization] Get rid of <cstddef> dependency in __datasizeof (PR #107394)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 5 05:46:32 PDT 2024


================
@@ -37,15 +37,15 @@ struct _FirstPaddingByte {
   char __first_padding_byte_;
 };
 
-// _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow
-// the use as an extension.
+// _FirstPaddingByte<> is sometimes non-standard layout.
+// Using `__builtin_offsetof` is UB in that case, but GCC and Clang allow the use as an extension.
----------------
frederick-vs-ja wrote:

I guess we shouldn't say UB here as [LWG2709](https://cplusplus.github.io/LWG/issue2709) changed the use from UB to a conditionally-supported feature. It seems fine to still say that it's an extension.

However, isn't `__builtin_offsetof` (not `offsetof`) **always** an extension?

```suggestion
// Using `__builtin_offsetof` is conditionally-supported, but GCC and Clang allow the use as an extension.
```

https://github.com/llvm/llvm-project/pull/107394


More information about the libcxx-commits mailing list