[clang] [Clang] Fix missing diagnostic for non-standard layout type in `offsetof` (PR #65246)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 21 23:06:51 PDT 2023


kasuga-fj wrote:

Thank you for your review! Here are some comments and my thoughts.

> Note that you should probably rebase your patch onto main and force-push to update the PR

Does it mean that I can rebase and force-push since (it should be avoided in normal case but) this is a special case?

> So... should we strive to eradicate this from libc++ in the first place, or should we just silence the warning. WDYT?

I think it's good to only silence the warning and (if necessary) leave some TODO comments about the `offsetof` usage because it's undesirable for this patch to be larger than it needs to be..

> Also, given that it is conditionally supported in C++17, I assume this warning doesn't trigger at all in C++17 mode, right?

I believe the purpose of this warning is to tell you that your program works now, but may not be compiled with another compiler. So the similar warning should appear even in C++17 mode. I chedked and found that `_FirstPaddingByte<>` is standard layout but non-POD (I checked them with `std::is_standard_layout` and `std::is_pod`). Using `offsetof` with a standard-layout class is supported in C++17, so I guess there is no warning 

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


More information about the cfe-commits mailing list