On Fri, Apr 04, 2014 at 04:48:48PM +0100, Jonathan Wakely wrote: > On 04/04/14 09:17 -0600, Jeff Law wrote: > >So what are those circumstances? ISTM this deserves some kind of > >comment at the least. > > I found the ICE using ubsan on the libstdc++ testsuite. Including the > bits/stdc++.h PCH'd header (i.e. the entire library) seemed to trigger > it. So either related to PCH, or just huge translation units ... not > sure of the exact cause.
So what happens here is that normally we initialize the builtins via c_common_nodes_and_builtins, which has: 5711 if (!flag_preprocess_only) 5712 c_define_builtins (va_list_ref_type_node, va_list_arg_type_node); c_define_builtins defines builtins in builtins.def, that includes even sanitizer.def. I guess that flag_preprocess_only was in effect due to PCH and we didn't define the builtins. I still haven't managed to create some sweet & small testcase, but I've found another ICE with PCH: $ touch y.h $ cat y.c #include "y.h" int main () {} $ gcc y.h $ gcc y.c -fsanitize=undefined -S y.c: In function ‘main’: y.c:2:1: internal compiler error: Segmentation fault int main () {} ^ 0x9a20df crash_signal /home/marek/src/gcc/gcc/toplev.c:337 0x52dfde bind /home/marek/src/gcc/gcc/c/c-decl.c:646 0x53767f c_builtin_function(tree_node*) /home/marek/src/gcc/gcc/c/c-decl.c:3664 0x875340 add_builtin_function_common /home/marek/src/gcc/gcc/langhooks.c:573 0x875ff3 add_builtin_function(char const*, tree_node*, int, built_in_class, char const*, tree_node*) /home/marek/src/gcc/gcc/langhooks.c:589 0x9b46ba initialize_sanitizer_builtins() /home/marek/src/gcc/gcc/sanitizer.def:30 0x9bfca5 ubsan_pass /home/marek/src/gcc/gcc/ubsan.c:870 0x9bfca5 execute /home/marek/src/gcc/gcc/ubsan.c:938 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. Marek