[12] RFR: 8214777: Avoid some GCC 8.X strncpy() errors in HotSpot

Kim Barrett kim.barrett at oracle.com
Tue Dec 11 17:05:52 UTC 2018


> On Dec 11, 2018, at 11:14 AM, Kim Barrett <kim.barrett at oracle.com> wrote:
> 
>> On Dec 10, 2018, at 1:57 PM, Simon Tooke <stooke at redhat.com> wrote:
>> 
>> This small patch fixes some simple warnings in Hotspot code, found by
>> GCC 8.1
> 
> What, exactly, is the warning?
> 
> Whatever the warning is, having common false positives is really unpleasant, and should be reported.
> Is there a gcc bug for this?  Is the warning sufficiently fine grained to be reasonable to disable?  Or
> maybe disable until such time as the false positives get fixed?

Answering my own question, probably -Wstringop-truncation.

And the documentation seems to suggest code exactly like the original
(e.g. storing a NUL at the end of the destination) ought to suppress
the warning. That's also suggested in a comment here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85902

This warning seems to have a bit of a bug tail, some of which have
been fixed, but might not be fixed in the gcc version you are using.
A couple of possibly relevant examples:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84468
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84480

Maybe we should just globally suppress this warning for gcc8.x (where
it is new), and revisit later.



More information about the hotspot-runtime-dev mailing list