I had gcc 4.1.1 configured in such a way that when the resulting cc1 got invoked, the stat() call in remove_duplicates() failed with an errno different than ENOENT (calling chain at that moment was: remove_duplications() <- merge_include_chains() <- register_include_chains() <- c_common_post_options() <- toplev_main()).
This results in calling cpp_errno() -> cpp_error() -> _cpp_begin_message() and finally print_location() which ICEs because map variable was NULL. The reason is that print_location()'s 'line' parameter was bogus (random value). That value was determined in cpp_error() as src_loc : "src_loc = pfile->cur_token[-1].src_loc;". The pfile->cur_token[-1] struct contains bogus values at this point. In attached patch I address this ICE twofold: 1) Make src_loc 0 in cpp_error() when no tokens have been read yet. 2) Check for NULL result of linemap_lookup(). -- Summary: [libcpp] ICE in print_location() when stat() in remove_duplicates() fails Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: John dot Tytgat at aaug dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32564