[Bug c/63178] New: Missed "incorrect-type-passed-to-function warning"
gccbugs at dima dot secretsauce.net
gcc-bugzilla@gcc.gnu.org
Thu Sep 4 18:07:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63178
Bug ID: 63178
Summary: Missed "incorrect-type-passed-to-function warning"
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: gccbugs at dima dot secretsauce.net
Hi. I'm seeing that under particular conditions I can pass a wrong type into a
function, and no warning results. I'm attaching a minimized test case to show
this. There are two files: bugreport.c and bugreport.h. The .c includes the .h.
The issue only happens when the .h file is placed into /usr/include, and
included using <> instead of "".
bugreport.c has this snippet:
typedef ... sss_t;
int fff( sss_t* ctx, ... )
...
sss_t* sss = NULL;
fff(&sss,0,0);
So fff() expects a sss_t* as its first argument, but we're giving it a sss_t**
instead. This should generate a warning. However:
dima@shorty:/tmp$ gcc-4.9 -Wall -Wextra -c -o/dev/null bugreport.c
<no output>
So gcc thinks this is fine. Tweaking the test case even a little bit makes the
warning come back. For instance, including the header in the local directory,
instead of in /usr/include makes it work, as does simply putting the header the
contents into the .c and including nothing. Removing the F() call makes it
work. Changing the whitespace in the F() call makes it work.
I'm using gcc 4.9.1 as shipped on Debian/sid:
dima@shorty:/tmp$ dpkg -l gcc-4.9
ii gcc-4.9 4.9.1-1
dima@shorty:/tmp$ gcc-4.9 -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc-4.9
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.1-1'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--disable-vtable-verify --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.1 (Debian 4.9.1-1)
Thanks
More information about the Gcc-bugs
mailing list