public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/25609]  New: too agressive printf optimization
@ 2005-12-30 22:59 drepper at redhat dot com
  2005-12-30 23:01 ` [Bug rtl-optimization/25609] " pinskia at gcc dot gnu dot org
                   ` (21 more replies)
  0 siblings, 22 replies; 24+ messages in thread
From: drepper at redhat dot com @ 2005-12-30 22:59 UTC (permalink / raw)
  To: gcc-bugs

At least glibc's printf, maybe others as well, print (null) in for code like

  printf ("%s", NULL)

gcc doesn't consider this when optimizing code where the pointer passed for a
%s format specifier can be NULL.  Example:

#include <stdio.h>
int
main (int argc, char *argv[])
{
  printf ("%s\n", argc > 1 ? argv[1] : NULL);
  return 0;
}

Compiling and running this code (I use gcc 4.0.2) will result in a program
which crashes because the printf is transformed into a puts() call and puts()
does not allow NULL pointers.

There should at least be a mode in which gcc does not perform the
transformation if it cannot be sure the pointer is not NULL.  The default for
Linux and maybe other platforms should be to not perform this optimization if
the pointer can be NULL.


-- 
           Summary: too agressive printf optimization
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drepper at redhat dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25609



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

end of thread, other threads:[~2008-01-16 12:37 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-30 22:59 [Bug rtl-optimization/25609] New: too agressive printf optimization drepper at redhat dot com
2005-12-30 23:01 ` [Bug rtl-optimization/25609] " pinskia at gcc dot gnu dot org
2005-12-30 23:05 ` pinskia at gcc dot gnu dot org
2005-12-30 23:05 ` pinskia at gcc dot gnu dot org
2005-12-30 23:06 ` drepper at redhat dot com
2005-12-30 23:07 ` pinskia at gcc dot gnu dot org
2005-12-30 23:08 ` pinskia at gcc dot gnu dot org
2005-12-30 23:08 ` drepper at redhat dot com
2005-12-30 23:15 ` drepper at redhat dot com
2005-12-30 23:37 ` pinskia at gcc dot gnu dot org
2005-12-30 23:44 ` drepper at redhat dot com
2005-12-30 23:49 ` pinskia at gcc dot gnu dot org
2005-12-31  0:19 ` drepper at redhat dot com
2006-01-01 22:18 ` joseph at codesourcery dot com
2007-11-16 16:17 ` manu at gcc dot gnu dot org
2007-11-16 22:11   ` Andrew Pinski
2007-11-16 22:11 ` pinskia at gmail dot com
2008-01-15 17:59 ` gustavodn at gmail dot com
2008-01-15 19:30 ` manu at gcc dot gnu dot org
2008-01-15 21:09 ` manu at gcc dot gnu dot org
2008-01-15 21:39 ` gustavodn at gmail dot com
2008-01-15 23:03 ` manu at gcc dot gnu dot org
2008-01-16  6:22 ` gustavodn at gmail dot com
2008-01-16 13:18 ` manu 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).