[Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null

manu at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Oct 1 09:12:00 GMT 2007



------- 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



More information about the Gcc-bugs mailing list