[Bug c++/54535] New: gcc fails to warn when functions are inlined
david at doublewise dot net
gcc-bugzilla@gcc.gnu.org
Sun Sep 9 14:45:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54535
Bug #: 54535
Summary: gcc fails to warn when functions are inlined
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: david@doublewise.net
#include <iostream>
namespace {
static void f(bool condition) {
volatile int const x = (__builtin_constant_p(condition) ? (1 /
(condition)) : 0); \
}
}
int main() {
f(false);
}
I compile this with -Werror=div-by-zero, and I do not get any warnings while
compiling. Instead, I get "Floating point exception (core dumped)" when I
attempt to run it.
The same sort of thing happens with other situations that should be warned
about, such as indexing an array with a negative number. I do get a warning if
I manually inline the call to f or make it a macro.
gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.0/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --disable-build-with-cxx
--disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id --with-linker-hash-style=gnu
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-initfini-array --enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC)
More information about the Gcc-bugs
mailing list