[Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line
barbieri at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Nov 18 18:08:00 GMT 2005
I'm writing a tutorial on a HelloWorld compiler front-end for GCC
(http://svn.gna.org/viewcvs/gsc/branches/hello-world/doc/hello.xml) and noticed
that a function with statements but no DECL_SOURCE_FILE set, seg-faults on
cgraph_finalize_function(), because it calls
gimple-low.c:lower_function_body(), which in turn does:
SET_EXPR_LOCATION (x, cfun->function_end_locus);
however, if cfun->function_end_locus is empty ({NULL, 0}), it will call
tree.c:annotate_with_file_line() with file=NULL, and it will fail on this "if":
if (last_annotated_node
&& last_annotated_node->line == line
&& (last_annotated_node->file == file
|| !strcmp (last_annotated_node->file, file)))
because strcmp (last_annotated_node->file, file), with file=NULL will
seg-fault.
The attached patch checks if file is NULL before using strcmp.
The program that fails build is:
http://svn.gna.org/viewcvs/gsc/branches/hello-world/compiler/hello1.c?rev=551
--
Summary: GCC segfault's on strcmp in
tree.c:annotate_with_file_line
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: barbieri at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24932
More information about the Gcc-bugs
mailing list