http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60304
Bug ID: 60304
Summary: Including disables -Wconversion-null
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: bug-reports at psdtechnologies dot com
Created attachment 32190
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32190&action=edit
Minimal example of bug (does not emit warning)
Compiling any code with '#include ' disables the conversion-null
warning, but only when compiling directly from source; preprocessing separately
does not reproduce the bug.
I've attached minimal examples, reproduced here since they're so short (1-2
lines)
This file behaves as expected (warning.cpp):
"""
int * foo() {return false;}
"""
$ g++-4.8 -std=c++11 -c warning.cpp
warning.cpp: In function ‘int* foo()’:
warning.cpp:1:21: warning: converting ‘false’ to pointer type ‘int*’
[-Wconversion-null]
int * foo() {return false;}
^
This warning is expected since -Wconversion-null is enabled by default. It also
can be made to error as expected using -Wall or by inserting
"""
#pragma GCC diagnostic error "-Wconversion-null"
"""
in the source prior to the function.
This file (differing only by the inclusion of does not issue the
warning, and cannot be made to error or warn even with the pragma:
"""
#include
int * foo() {return false;}
"""
g++-4.8 -std=c++11 -c nowarning.cpp # success
Compiling incrementally, though, restores the expected behavior:
g++-4.8 -std=c++11 -E nowarning.cpp -o nowarning.i # success
g++-4.8 -std=c++11 -c nowarning.i
nowarning.cpp: In function ‘int* foo()’:
nowarning.cpp:2:21: warning: converting ‘false’ to pointer type ‘int*’
[-Wconversion-null]
int * foo() {return false;}
^
As does using -save-temps:
g++-4.8 -std=c++11 -save-temps -c nowarning.cpp
nowarning.cpp: In function ‘int* foo()’:
nowarning.cpp:2:21: warning: converting ‘false’ to pointer type ‘int*’
[-Wconversion-null]
int * foo() {return false;}
^
Version information:
g++-4.8 -std=c++11 -v -c nowarning.cpp
Using built-in specs.
COLLECT_GCC=g++-4.8
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.8.1-2ubuntu1~12.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --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.8-amd64/jre
--enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64 --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.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04)
COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-c' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -quiet -v -imultilib . -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE nowarning.cpp -quiet -dumpbase nowarning.cpp
-mtune=generic -march=x86-64 -auxbase nowarning -std=c++11 -version
-fstack-protector -o /tmp/ccCyoaqJ.s
GNU C++ (Ubuntu 4.8.1-2ubuntu1~12.04) version 4.8.1 (x86_64-linux-gnu)
compiled by GNU C version 4.8.1, GMP version 5.0.2, MPFR version 3.1.0-p3,
MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8/.
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C++ (Ubuntu 4.8.1-2ubu