[Bug c/96293] Extraneously noisy "taking address of packed member may result in an unaligned pointer value"

2022-07-07 Thread ldeng at mail dot ustc.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96293 --- Comment #9 from Long Deng --- I take your point, although there seems to be a slight problem with your example. In your code, `&a->record.data[0]` is not a well-aligned access, because `struct attribute` is defined as packed, so compiler has

[Bug c/96293] Extraneously noisy "taking address of packed member may result in an unaligned pointer value"

2022-07-06 Thread ldeng at mail dot ustc.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96293 --- Comment #6 from Long Deng --- I met the same problem. I found that gcc issue this warning probably because `struct S` can located any address, which means that `s.d` may not alignment to 4. So as Richard said, you can use `__attribute__((pack