[PATCH] correct handling of indices into arrays with elements larger than 1 (PR c++/96511)
Tue Aug 11 16:19:16 GMT 2020
-Wplacement-new handles array indices and pointer offsets the same:
by adjusting them by the size of the element. That's correct for
the latter but wrong for the former, causing false positives when
the element size is greater than one.
In addition, the warning doesn't even attempt to handle arrays of
arrays. I'm not sure if I forgot or if I simply didn't think of
The attached patch corrects these oversights by replacing most
of the -Wplacement-new code with a call to compute_objsize which
handles all this correctly (plus more), and is also better tested.
But even compute_objsize has bugs: it trips up while converting
wide_int to offset_int for some pointer offset ranges. Since
handling the C++ IL required changes in this area the patch also
For review purposes, the patch affects just the middle end.
The C++ diff pretty much just removes code from the front end.
Tested on x86_64-linux plus by building the latest Glibc and
confirming no new warnings.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 44051 bytes
Desc: not available
More information about the Gcc-patches