From owner-freebsd-current@FreeBSD.ORG Tue Mar 13 16:22:04 2007 Return-Path: X-Original-To: freebsd-current@FreeBSD.ORG Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DAB6B16A40B; Tue, 13 Mar 2007 16:22:04 +0000 (UTC) (envelope-from rnsanchez@wait4.org) Received: from spunkymail-a11.g.dreamhost.com (sd-green-bigip-207.dreamhost.com [208.97.132.207]) by mx1.freebsd.org (Postfix) with ESMTP id A7FC113C4C8; Tue, 13 Mar 2007 16:22:04 +0000 (UTC) (envelope-from rnsanchez@wait4.org) Received: from sauron.lan.box (unknown [200.180.163.93]) by spunkymail-a11.g.dreamhost.com (Postfix) with ESMTP id 6E949B7098; Tue, 13 Mar 2007 09:22:01 -0700 (PDT) Date: Tue, 13 Mar 2007 13:21:58 -0300 From: Ricardo Nabinger Sanchez To: Maxime Henrion 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> Organization: SYS_WAIT4 X-Mailer: Sylpheed 2.4.0beta4 (GTK+ 2.10.9; i386-unknown-freebsd6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-bugs@FreeBSD.ORG, freebsd-current@FreeBSD.ORG Subject: Re: Bad gcc -O optimization cause core dump. What to do? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Mar 2007 16:22:05 -0000 On Tue, 13 Mar 2007 15:06:32 +0100 Maxime Henrion 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 Powered by FreeBSD "Left to themselves, things tend to go from bad to worse."