Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Mar 2007 13:21:58 -0300
From:      Ricardo Nabinger Sanchez <rnsanchez@wait4.org>
To:        Maxime Henrion <mux@FreeBSD.org>
Cc:        freebsd-bugs@FreeBSD.ORG, freebsd-current@FreeBSD.ORG
Subject:   Re: Bad gcc -O optimization cause core dump. What to do?
Message-ID:  <20070313132158.7368d186.rnsanchez@wait4.org>
In-Reply-To: <20070313140632.GK65356@elvis.mu.org>
References:  <20070313121106.GA96293@nagual.pp.ru> <20070313101312.71d35c32.rnsanchez@wait4.org> <20070313140632.GK65356@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 13 Mar 2007 15:06:32 +0100
Maxime Henrion <mux@FreeBSD.org> wrote:

> > Given that this is not what the user asked (replacing printf with puts), I
> > consider this a bug.  GCC made its assumption, and it was incorrect--it's
> > not user's fault.
> 
> GCC can do whatever it wants here, even printing "foobar42", because the
> C standard says that passing a NULL pointer to a %s format will yield
> undefined behaviour.  It *is* user's fault to have passed NULL to
> printf() in the first place.
> 
> So, while we could argue that GCC's behaviour here is useless, annoying,
> etc, this just can't be called a bug in GCC.  As a side note, these
> "optimizations" are in place since a *long* time now.

... Considered until now.  :)

Honestly, I wasn't aware of these specific issues (detail in the C standard +
gcc builtin printf optimization), and that's surely _my_ fault, not gcc's.

Sorry for the (useless) noise.  Thank you (and DES) for pointing this out.

-- 
Ricardo Nabinger Sanchez     <rnsanchez@{gmail.com,wait4.org}>
Powered by FreeBSD

  "Left to themselves, things tend to go from bad to worse."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070313132158.7368d186.rnsanchez>