From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25840 invoked by alias); 9 Oct 2014 07:15:28 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 25828 invoked by uid 89); 9 Oct 2014 07:15:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 09 Oct 2014 07:15:27 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s997FPW2011192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 9 Oct 2014 03:15:25 -0400 Received: from tucnak.zalov.cz (ovpn-116-116.ams2.redhat.com [10.36.116.116]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s997FNjP028996 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Thu, 9 Oct 2014 03:15:24 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.9/8.14.9) with ESMTP id s997FLCd027047; Thu, 9 Oct 2014 09:15:21 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.14.9/8.14.9/Submit) id s997FK0e027046; Thu, 9 Oct 2014 09:15:20 +0200 Date: Thu, 09 Oct 2014 07:15:00 -0000 From: Jakub Jelinek To: Rongqing Li Cc: gcc-bugs@gcc.gnu.org Subject: Re: gcc 4.9.1 Bug or not Message-ID: <20141009071520.GA27016@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <54362331.8060202@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54362331.8060202@windriver.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2014-10/txt/msg00642.txt.bz2 On Thu, Oct 09, 2014 at 01:54:57PM +0800, Rongqing Li wrote: > The attachment is a piece of C code. > When compile it with -O2 option, a segfault occurs: > > strncpy(new, old, cp-old); It is a bug of course, but in the testcase. Calling strncpy with NULL second argument, even when the size is 0, is undefined behavior. See http://gcc.gnu.org/gcc-4.9/porting_to.html