Bug 86451 - Incorrect "is used uninitialized"
Summary: Incorrect "is used uninitialized"
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 8.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-10 07:55 UTC by Jan Wielemaker
Modified: 2018-07-10 08:32 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
C source file (short, no includes) (126 bytes, text/plain)
2018-07-10 07:55 UTC, Jan Wielemaker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Wielemaker 2018-07-10 07:55:33 UTC
Created attachment 44369 [details]
C source file (short, no includes)

On quite a few versions I get this (I think) incorrect message:

t.c: In function ‘t’:
t.c:9:12: warning: ‘t’ is used uninitialized in this function [-Wuninitialized]
     key ^= *p;

Compiled using 

gcc -v -save-temps -c -Wall -O2 t.c

Below is the complete console output up to the warning.  Note that this is a simplified version of the real code.  The 0.0 is normally
a function call.

       Thanks --- Jan

Using built-in specs.
COLLECT_GCC=gcc
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.1.1 20180502 (Red Hat 8.1.1-1) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-Wall' '-O2' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/8/cc1 -E -quiet -v t.c -mtune=generic -march=x86-64 -Wall -O2 -fpch-preprocess -o t.i
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/8/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/8/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /ufs/wielemak/include
 /usr/lib/gcc/x86_64-redhat-linux/8/include
 /usr/local/include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-Wall' '-O2' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/8/cc1 -fpreprocessed t.i -quiet -dumpbase t.c -mtune=generic -march=x86-64 -auxbase t -O2 -Wall -version -o t.s
GNU C17 (GCC) version 8.1.1 20180502 (Red Hat 8.1.1-1) (x86_64-redhat-linux)
	compiled by GNU C version 8.1.1 20180502 (Red Hat 8.1.1-1), GMP version 6.1.2, MPFR version 3.1.6-p2, MPC version 1.0.2, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C17 (GCC) version 8.1.1 20180502 (Red Hat 8.1.1-1) (x86_64-redhat-linux)
	compiled by GNU C version 8.1.1 20180502 (Red Hat 8.1.1-1), GMP version 6.1.2, MPFR version 3.1.6-p2, MPC version 1.0.2, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: f4961d4fd1326e1750d95d53d7feee3c
t.c: In function ‘t’:
t.c:9:12: warning: ‘t’ is used uninitialized in this function [-Wuninitialized]
     key ^= *p;
            ^~
Comment 1 Andrew Pinski 2018-07-10 08:04:37 UTC
Try with -fno-strict-aliasing because I suspect you are violating the c/c++ aliasing rules in that you access a double as an unsigned long.
Comment 2 Jan Wielemaker 2018-07-10 08:32:28 UTC
Thanks.  Aliasing ... after all those years ...  Rewrote using a union and now it is nice and silent.  Marked as invalid.