[Bug c++/55870] New: Compiler crash when template includes sizeof of something that shouldn't be dereferenced
dspeyer at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jan 3 22:39:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55870
Bug #: 55870
Summary: Compiler crash when template includes sizeof of
something that shouldn't be dereferenced
Classification: Unclassified
Product: gcc
Version: 4.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dspeyer@gmail.com
Created attachment 29079
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29079
Preprocessed Source Code
The compiler said "internal compiler error: Segmentation fault. Please submit a
full bug report" so I am. I realize there are few safe things to do with a
dereferenced null pointer, but usually sizeof is one of them.
Source code is attached. I think the critical line is:
template<typename b> static void*
val(silliness<sizeof(static_cast<b*>(NULL)->s1)>*)
which was supposed to specialize if and only if b::s1 existed. As you may have
guessed, this was an attempt to figure out why saner sfinae mechanisms weren't
working.
Here's the compiler output:
g++ -v --save-temps -o sfinae sfinae.cc
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4'
--with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3
--program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-mpfr --enable-targets=all --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'sfinae' '-shared-libgcc'
'-mtune=generic'
/usr/lib/gcc/i486-linux-gnu/4.3.3/cc1plus -E -quiet -v -D_GNU_SOURCE sfinae.cc
-D_FORTIFY_SOURCE=2 -mtune=generic -fpch-preprocess -o sfinae.ii
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.3.3/../../../../i486-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.3
/usr/include/c++/4.3/i486-linux-gnu
/usr/include/c++/4.3/backward
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.3.3/include
/usr/lib/gcc/i486-linux-gnu/4.3.3/include-fixed
/usr/include/i486-linux-gnu
/usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'sfinae' '-shared-libgcc'
'-mtune=generic'
/usr/lib/gcc/i486-linux-gnu/4.3.3/cc1plus -fpreprocessed sfinae.ii -quiet
-dumpbase sfinae.cc -mtune=generic -auxbase sfinae -version -fstack-protector
-o sfinae.s
GNU C++ (Ubuntu 4.3.3-5ubuntu4) version 4.3.3 (i486-linux-gnu)
compiled by GNU C version 4.3.3, GMP version 4.2.4, MPFR version 2.4.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: e2b5a0303075a65d33d75f9466062812
sfinae.cc:28: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.3/README.Bugs> for instructions.
More information about the Gcc-bugs
mailing list