public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null
       [not found] <bug-15685-8634@http.gcc.gnu.org/bugzilla/>
@ 2005-12-30 23:07 ` pinskia at gcc dot gnu dot org
  2005-12-30 23:49 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-30 23:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2005-12-30 23:07 -------
*** Bug 25609 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |drepper at redhat dot com


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



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

* [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null
       [not found] <bug-15685-8634@http.gcc.gnu.org/bugzilla/>
  2005-12-30 23:07 ` [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null pinskia at gcc dot gnu dot org
@ 2005-12-30 23:49 ` pinskia at gcc dot gnu dot org
  2007-10-01  6:45 ` mathias dot hasselmann at gmx dot de
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-12-30 23:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2005-12-30 23:49 -------
*** Bug 25609 has been marked as a duplicate of this bug. ***


-- 


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



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

* [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null
       [not found] <bug-15685-8634@http.gcc.gnu.org/bugzilla/>
  2005-12-30 23:07 ` [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null pinskia at gcc dot gnu dot org
  2005-12-30 23:49 ` pinskia at gcc dot gnu dot org
@ 2007-10-01  6:45 ` mathias dot hasselmann at gmx dot de
  2007-10-01  9:12 ` manu at gcc dot gnu dot org
  2007-10-19 14:47 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: mathias dot hasselmann at gmx dot de @ 2007-10-01  6:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from mathias dot hasselmann at gmx dot de  2007-10-01 06:45 -------
(In reply to comment #1)
> Not a bug as printf can segfault if it is supplied a NULL pointer for the
> string formatter.
> If glibc does something different than that, glibc is does not have a bug
> either as it is undefined really 
> so converting the call to a puts is a vaild transformation.
> 
Even if its a valid transformation, there is the question if this is a
reasonable transformation. Obviously that optimization was introduced because
quite alot of people do not know about the puts function and use printf to
output static lines of text. On the other hand there are people who rely on
glibc's handling of the undefined NULL pointer situation.

Question is: Which group is bigger. The missuse printf as puts group or the
rely on glibc's relaxed NULL handling group. My guess would be that people who
do not even know puts care even less about the fact that ANSI and ISO didn't
care about NULL handling in format strings. If that would true, this
optimization would be valid, but unreasonable as it breaks the expections of
your clients.


-- 


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


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

* [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null
       [not found] <bug-15685-8634@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2007-10-01  6:45 ` mathias dot hasselmann at gmx dot de
@ 2007-10-01  9:12 ` manu at gcc dot gnu dot org
  2007-10-19 14:47 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-10-01  9:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from manu at gcc dot gnu dot org  2007-10-01 09:12 -------
(In reply to comment #4)
> Question is: Which group is bigger. The missuse printf as puts group or the
> rely on glibc's relaxed NULL handling group. My guess would be that people who
> do not even know puts care even less about the fact that ANSI and ISO didn't
> care about NULL handling in format strings. If that would true, this
> optimization would be valid, but unreasonable as it breaks the expections of
> your clients.

The expectations of our "clients" is to follow standards while producing
fastest code possible. Glibc behaviour is inconsistent here. In principle there
should be no difference between puts(s) and printf("%s",s) and fprintf(stdout,
"%s", s). Imagine that the two last ones did something different (I haven't
tested, so they actually may) when s == NULL, wouldn't you consider it glibc's
fault? Then, why you don't request the same for puts(s)? 


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org


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


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

* [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null
       [not found] <bug-15685-8634@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2007-10-01  9:12 ` manu at gcc dot gnu dot org
@ 2007-10-19 14:47 ` manu at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-10-19 14:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from manu at gcc dot gnu dot org  2007-10-19 14:46 -------
Just for reference. Neither fprintf() nor sprintf() seem to follow the
behaviour of printf() in glibc 2.5.


-- 


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


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

* [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null
  2004-05-28  3:19 [Bug c/15685] New: " mikko dot tiihonen at hut dot fi
@ 2004-05-28  3:31 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-28  3:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-27 17:10 -------
Not a bug as printf can segfault if it is supplied a NULL pointer for the string formatter.
If glibc does something different than that, glibc is does not have a bug either as it is undefined really 
so converting the call to a puts is a vaild transformation.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2007-10-19 14:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-15685-8634@http.gcc.gnu.org/bugzilla/>
2005-12-30 23:07 ` [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null pinskia at gcc dot gnu dot org
2005-12-30 23:49 ` pinskia at gcc dot gnu dot org
2007-10-01  6:45 ` mathias dot hasselmann at gmx dot de
2007-10-01  9:12 ` manu at gcc dot gnu dot org
2007-10-19 14:47 ` manu at gcc dot gnu dot org
2004-05-28  3:19 [Bug c/15685] New: " mikko dot tiihonen at hut dot fi
2004-05-28  3:31 ` [Bug c/15685] " pinskia 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).