rnk added a comment.

In addition to the ABI compatibility concern, IMO, GCC's behavior here is 
better and more user friendly:

- C++ classes have methods
- calling a method on a field takes the address of a field
- if the field is in a packed struct, it may be misaligned
- misaligned loads and stores cause UB
- the UB is not trivial or hypothetical: it manifests as a crash, or load/store 
tearing or non-atomicity

GCC prevents users from getting into this situation by ignoring the packed 
attribute in the presence of non-C++98-POD fields and warning the user about 
it. Clang should do the same. Currently, Clang's stance seems to be, if the 
user asks permission to shoot themselves in the foot, they can go right ahead. 
That's less than ideal.

Between the usability concern and the ABI concern, it seems worth changing 
behavior here, even if it means leaving behind a flag or a new attribute such 
as `__attribute__((packed_nonpod))` to get the old behavior. I don't see a PS4 
reviewer here, but every time I've asked them if we can tweak some ABI detail, 
they ask to be opted out.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117616/new/

https://reviews.llvm.org/D117616

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to