public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mathias dot hasselmann at gmx dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/15685] printf("%s\n") optimized to puts also when parameter might be null
Date: Mon, 01 Oct 2007 06:45:00 -0000	[thread overview]
Message-ID: <20071001064541.374.qmail@sourceware.org> (raw)
In-Reply-To: <bug-15685-8634@http.gcc.gnu.org/bugzilla/>



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


  parent reply	other threads:[~2007-10-01  6:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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
2007-10-01  6:45 ` mathias dot hasselmann at gmx dot de [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071001064541.374.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).