On 09/06/2016 11:31 PM, Paul Eggert wrote:
On 09/06/2016 01:40 PM, Joseph Myers wrote:
Sounds like a defect in C11 to me - none of the examples of flexible
array
members anticipate needing to add to the size to allow for tail padding
with unknown alignment requirements.

Yes, I would prefer calling it a defect, as most code I've seen dealing
with flexible array members does not align the tail size. However, GCC +
valgrind does take advantage of this "defect" and I would not be
surprised if other picky implementations do too.

It might be an inherent limitation of the valgrind approach. Speculative loads which cannot result in data races (in the C11 sense) due to the way the architecture behaves should be fine. The alignment ensures that the load is on the same page, which is what typically prevent this optimization.

Some implementation techniques for C string functions result in the same behavior. valgrind intercepts them or suppresses errors there, but that's not possible for code that GCC emits inline, obviously.

valgrind would still treat the bytes beyond the allocation boundary as undefined. But I agree that false positives in this area are annoying.

Florian

Reply via email to