From owner-freebsd-bugs@FreeBSD.ORG Tue Mar 13 13:13:19 2007 Return-Path: X-Original-To: freebsd-bugs@FreeBSD.ORG Delivered-To: freebsd-bugs@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7E38D16A479 for ; Tue, 13 Mar 2007 13:13:19 +0000 (UTC) (envelope-from rnsanchez@wait4.org) Received: from spunkymail-a5.g.dreamhost.com (sd-green-bigip-81.dreamhost.com [208.97.132.81]) by mx1.freebsd.org (Postfix) with ESMTP id 539A813C45B for ; Tue, 13 Mar 2007 13:13:19 +0000 (UTC) (envelope-from rnsanchez@wait4.org) Received: from sauron.lan.box (unknown [200.180.160.204]) by spunkymail-a5.g.dreamhost.com (Postfix) with ESMTP id 0BCAA14D6B4; Tue, 13 Mar 2007 06:13:16 -0700 (PDT) Date: Tue, 13 Mar 2007 10:13:12 -0300 From: Ricardo Nabinger Sanchez To: Andrey Chernov Message-Id: <20070313101312.71d35c32.rnsanchez@wait4.org> In-Reply-To: <20070313121106.GA96293@nagual.pp.ru> References: <20070313121106.GA96293@nagual.pp.ru> 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-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Mar 2007 13:13:19 -0000 On Tue, 13 Mar 2007 15:11:07 +0300 Andrey Chernov wrote: > cc -O -S a.c > .file "a.c" > .text > .p2align 2,,3 > .globl main > .type main, @function > main: > pushl %ebp > movl %esp, %ebp > subl $8, %esp > andl $-16, %esp > subl $28, %esp > pushl $0 > call puts > leave > ret > .size main, .-main > .ident "GCC: (GNU) 3.4.6 [FreeBSD] 20060825" Confirmed on FreeBSD-6.1 RELEASE: .file "bla.c" .text .p2align 2,,3 .globl main .type main, @function main: pushl %ebp movl %esp, %ebp subl $8, %esp andl $-16, %esp subl $28, %esp pushl $0 call puts leave ret .size main, .-main .ident "GCC: (GNU) 3.4.4 [FreeBSD] 20050518" > It calls "puts(NULL)" with core dump. > It means "printf("%s\n", NULL)" is overoptimized. > BTW, things like "printf("1%s\n", NULL)" are not overoptimized. > Any ideas? Is it right or needs to be fixed? 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. -- Ricardo Nabinger Sanchez Powered by FreeBSD "Left to themselves, things tend to go from bad to worse."