Bug 413642

Summary: gcc 9 with -O2 results in false positive: Uninitialised value was created by a stack allocation
Product: [Developer tools] valgrind Reporter: Tim Rühsen <tim.ruehsen>
Component: memcheckAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version: 3.15 SVN   
Target Milestone: ---   
Platform: Debian unstable   
OS: Linux   
Latest Commit: Version Fixed In:

Description Tim Rühsen 2019-10-30 17:03:20 UTC
SUMMARY
Valgrind falsely detects "Uninitialised value was created by a stack allocation" when the code is compiled with gcc 9 and -O2 (with -O0 all is fine).

It looks like it's about how gcc optimizes strcmp().

STEPS TO REPRODUCE
All is pretty well described (incl. dgb assembler dumps) at
https://gitlab.com/gnutls/libtasn1/issues/9

OBSERVED RESULT
==15173== Conditional jump or move depends on uninitialised value(s)
==15173==    at 0x1092C0: main (Test_choice.c:122)
==15173==  Uninitialised value was created by a stack allocation
==15173==    at 0x1090F0: main (Test_choice.c:28)

EXPECTED RESULT
No report at all - the variable is being initialized in a called function.

SOFTWARE/OS VERSIONS
Debian unstable, but also reported on Fedora. Key seems to be gcc 9.

ADDITIONAL INFORMATION
https://gitlab.com/gnutls/libtasn1/issues/9