https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117305
Bug ID: 117305 Summary: include files processed differently depending on directory they were fetched from Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: joakim.rosqvist at gmail dot com Target Milestone: --- Hi. (I know the reporting instruction says not to submit .h files but I need to do that as it is the processing of them that seems to be the issue) The included test program rotates a 64 bit integer a number of steps determined by the variable d, whose value is not defined in the program. Thus, a warning about an uninitialized variable is expected. The rotate function is normally defined in <immintrin.h>. For brevity I have extracted the relevant parts in myia32intrin.h: #define _lrotl(a,b) __rolq((a), (b)) unsigned long long __rolq (unsigned long long __X, int __C) { __C &= 63; return (__X << __C) | (__X >> (-__C & 63)); } The C program that uses the above include file looks like so (foo.c): #include "myia32intrin.h" int main(int , char *[]) { int d; return _lrotl(1, d+1); } Let's compile it: >gcc -O -Wuninitialized -o foo foo.c myia32intrin.h:2:33: warning: ‘d’ is used uninitialized [-Wuninitialized] 2 | #define _lrotl(a,b) __rolq((a), (b)) | ^~~~~~~~~~~~~~~~ foo.c:7:12: note: in expansion of macro ‘_lrotl’ 7 | return _lrotl(1, d+1); | ^~~~~~ foo.c:5:9: note: ‘d’ was declared here 5 | int d; | ^ Indeed, I did get the expected warning about 'd' being used uninitialized. However, now I move myia32intrin.h to /usr/lib/gcc/x86_64-linux-gnu/14/include/ (i.e. where <immintrin.h> an friends live) and change the C program to find the include file among the system headers by using angle brackets: #include <myia32intrin.h> int main(int , char *[]) { int d; return _lrotl(1, d+1); } And then compile again as above: >gcc -O -Wuninitialized -o foo foo.c This time there is no warning about the uninitialized variable! Here is the preprocessed C file in the case where I include a local file and do get a warning (foo_works.i): # 0 "foo.c" # 0 "<built-in>" # 0 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 0 "<command-line>" 2 # 1 "foo.c" # 1 "myia32intrin.h" 1 unsigned long long __rolq (unsigned long long __X, int __C) { __C &= 63; return (__X << __C) | (__X >> (-__C & 63)); } # 2 "foo.c" 2 int main(int , char *[]) { int d; return __rolq((1), (d+1)); } And here is the preprocessed C file in the case where I include a system header file and don't get a warning (foo_fail.i): # 0 "foo.c" # 0 "<built-in>" # 0 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 0 "<command-line>" 2 # 1 "foo.c" # 1 "/usr/lib/gcc/x86_64-linux-gnu/14/include/myia32intrin.h" 1 3 4 # 4 "/usr/lib/gcc/x86_64-linux-gnu/14/include/myia32intrin.h" 3 4 unsigned long long __rolq (unsigned long long __X, int __C) { __C &= 63; return (__X << __C) | (__X >> (-__C & 63)); } # 2 "foo.c" 2 # 3 "foo.c" int main(int , char *[]) { int d; return # 7 "foo.c" 3 4 __rolq(( # 7 "foo.c" 1 # 7 "foo.c" 3 4 ), ( # 7 "foo.c" d+1 # 7 "foo.c" 3 4 )) # 7 "foo.c" ; } Finally, the output of gcc -v: Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/14/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 14.2.0-4ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr --with-gcc-major-version-only --program-suffix=-14 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-14-zdkDXv/gcc-14-14.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-14-zdkDXv/gcc-14-14.2.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 14.2.0 (Ubuntu 14.2.0-4ubuntu2)