From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1547 invoked by alias); 18 Nov 2005 18:08:37 -0000 Received: (qmail 1539 invoked by uid 48); 18 Nov 2005 18:08:33 -0000 Date: Fri, 18 Nov 2005 18:08:00 -0000 Subject: [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "barbieri at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2005-11/txt/msg02596.txt.bz2 List-Id: 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