Bug#966194: gcc-9: valgrind error: Conditional jump or move depends on uninitialised value(s)
Package: gcc-9
Version: 9.3.0-15
Severity: important
X-Debbugs-Cc: rick@scotsgeek.com
Dear Maintainer,
Source:
#include <stdio.h>
#include <string.h>
#define DIM 32
char p[DIM] = "NULL";
int main(void)
{
strcpy(p, "This is a test.");
for(int x = 0 ; x < DIM; ++x)
{
printf("%02x ", p[x]);
}
putchar('\n');
return 0;
}
valgrind output:
==16291== Use of uninitialised value of size 8
==16291== at 0x48B4E5A: _itoa_word (_itoa.c:180)
==16291== by 0x48CE753: __vfprintf_internal (vfprintf-internal.c:1687)
==16291== by 0x48BAD6A: printf (printf.c:33)
==16291== by 0x10920D: main (ptest.c:33)
==16291==
==16291== Conditional jump or move depends on uninitialised value(s)
==16291== at 0x48B4E6C: _itoa_word (_itoa.c:180)
==16291== by 0x48CE753: __vfprintf_internal (vfprintf-internal.c:1687)
==16291== by 0x48BAD6A: printf (printf.c:33)
==16291== by 0x10920D: main (ptest.c:33)
==16291==
...
==16291== ERROR SUMMARY: 64 errors from 4 contexts (suppressed: 0 from 0)
Error only occurs with heap allocation, not with global or local arrays.
Error did not occur with previous versions of gcc. Compilation command has not changed.
"gcc -std=c18 -Wall -Wextra -Wpedantic -g -I . -o ptest ptest.c"
Error should not occur with the code posted here.
-- System Information:
Debian Release: bullseye/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)
Kernel: Linux 5.7.0-1-amd64 (SMP w/4 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Versions of packages gcc-9 depends on:
ii binutils 2.34.90.20200706-1
ii cpp-9 9.3.0-15
ii gcc-9-base 9.3.0-15
ii libc6 2.31-1
ii libcc1-0 10.1.0-6
ii libgcc-9-dev 9.3.0-15
ii libgcc-s1 10.1.0-6
ii libgmp10 2:6.2.0+dfsg-6
ii libisl22 0.22.1-1
ii libmpc3 1.1.0-1
ii libmpfr6 4.0.2-1
ii libstdc++6 10.1.0-6
ii zlib1g 1:1.2.11.dfsg-2
Versions of packages gcc-9 recommends:
ii libc6-dev 2.31-1
Versions of packages gcc-9 suggests:
pn gcc-9-doc <none>
pn gcc-9-locales <none>
pn gcc-9-multilib <none>
-- no debconf information
Reply to: