RFR(XS): 8252051: Make mlvmJvmtiUtils strncpy uses GCC 10.x friendly

Igor Ignatyev igor.ignatyev at oracle.com
Wed Aug 19 22:25:12 UTC 2020


LGTM
-- Igor

> On Aug 19, 2020, at 3:14 PM, Mikael Vidstedt <mikael.vidstedt at oracle.com> wrote:
> 
> 
> Please review this small change which updates the strncpy code in mlvmJvmtiUtils.cpp to make gcc 10.x happy:
> 
> JBS: https://bugs.openjdk.java.net/browse/JDK-8252051
> webrev: http://cr.openjdk.java.net/~mikael/webrevs/8252051/webrev.00/open/webrev/
> 
> * Background (from JBS)
> 
> gcc 10.2 is producing a warning for mlvmJmvtiUtils.cpp: 
> 
> In file included from test/hotspot/jtreg/vmTestbase/vm/mlvm/indy/func/jvmti/share/libIndyRedefineClass.cpp:31: 
> test/hotspot/jtreg/vmTestbase/vm/mlvm/share/mlvmJvmtiUtils.cpp:100:12: error: 'char* strncpy(char*, const char*, size_t)' specified bound 256 equals destination size [-Werror=stringop-truncation] 
>  100 | strncpy(mn->classSig, szSignature, sizeof(mn->classSig)); 
>      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
> cc1plus: all warnings being treated as errors 
> 
> It seems like gcc is not smart enough to realize that the strncpy on the previous line (mn->methodName) cannot modify szSignature.
> 
> 
> * Testing
> 
> tier1 and test/hotspot/jtreg:vmTestbase_vm_mlvm locally
> 
> 
> Cheers,
> Mikael
> 



More information about the hotspot-compiler-dev mailing list