public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/24932]  New: GCC segfault's on strcmp in tree.c:annotate_with_file_line
@ 2005-11-18 18:08 barbieri at gmail dot com
  2005-11-18 18:09 ` [Bug middle-end/24932] " barbieri at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: barbieri at gmail dot com @ 2005-11-18 18:08 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-02-22 16:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-18 18:08 [Bug middle-end/24932] New: GCC segfault's on strcmp in tree.c:annotate_with_file_line barbieri at gmail dot com
2005-11-18 18:09 ` [Bug middle-end/24932] " barbieri at gmail dot com
2005-11-18 18:17 ` pinskia at gcc dot gnu dot org
2005-11-18 18:36 ` barbieri at gmail dot com
2005-12-07 10:49 ` barbieri at gmail dot com
2005-12-24 22:47 ` barbieri at gmail dot com
2009-02-22 16:36 ` steven at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).