From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Engster Newsgroups: gmane.emacs.devel Subject: Re: Using stpcpy Date: Sat, 27 Dec 2014 21:03:10 +0100 Message-ID: <878uhsvp1d.fsf@engster.org> References: <549849A7.3070208@yandex.ru> <54991006.8030208@cs.ucla.edu> <54994677.9080608@yandex.ru> <549C0242.3010402@cs.ucla.edu> <549C4C7C.2070001@yandex.ru> <549CA168.8050002@cs.ucla.edu> <83zjaaksua.fsf@gnu.org> <83tx0hlen1.fsf@gnu.org> <83bnmolvkb.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1419710618 16931 80.91.229.3 (27 Dec 2014 20:03:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 27 Dec 2014 20:03:38 +0000 (UTC) Cc: chengang31@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 27 21:03:32 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y4xaF-0005Ee-Q8 for ged-emacs-devel@m.gmane.org; Sat, 27 Dec 2014 21:03:31 +0100 Original-Received: from localhost ([::1]:56787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y4xaF-00042X-4t for ged-emacs-devel@m.gmane.org; Sat, 27 Dec 2014 15:03:31 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y4xaB-00042P-TD for emacs-devel@gnu.org; Sat, 27 Dec 2014 15:03:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y4xa6-0008Lq-UM for emacs-devel@gnu.org; Sat, 27 Dec 2014 15:03:27 -0500 Original-Received: from randomsample.de ([5.45.97.173]:56899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y4xa6-0008Iy-L9; Sat, 27 Dec 2014 15:03:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=randomsample.de; s=a; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From; bh=Exxr0KgSqxFJgKzGwPvUSPdQmyL1+8c8sj+uGA87pz4=; b=YDxeDP6gUwL6H6mLG4IrXrvZK4cRqYTqOiZNG0qdZgDc3UGbJNArHzd0NdjPe0kDqcWsG4vVexCuBQM1SDvWrXobBoGMBjUBfyxDdb00lIhvgLU7VvD021ZaF3oDs1we; Original-Received: from ip4d154cb9.dynamic.kabel-deutschland.de ([77.21.76.185] helo=spaten) by randomsample.de with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1Y4xa0-0005S3-1y; Sat, 27 Dec 2014 21:03:16 +0100 In-Reply-To: <83bnmolvkb.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 27 Dec 2014 21:52:20 +0200") User-Agent: Gnus/5.13001 (Ma Gnus v0.10) Emacs/24.3.91 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 5.45.97.173 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:180720 Archived-At: Eli Zaretskii writes: >> From: cg >> Date: Sat, 27 Dec 2014 19:57:07 +0800 >> > >> On 12/27/2014 3:45 PM, Eli Zaretskii wrote: >> > >> > Sorry, I don't understand this: there's no call to stpcpy on line 350 >> > of ntlib.c, or anywhere else in ntlib.c, actually. That line calls >> > >> >> Yes, I was confused by the error message too, and found ntlib.c >> didin't use stpcpy at all. It looks like it has something to do with >> compiler optimization. >> >> So I tried to use different optimization flags, and this error only >> happens when -O2 or -Ofast is used as CFLAGS: >> >> ./autogen.sh >> export CFLASG=-O0 # no error >> #export CFLASG=-O1 # no error >> #export CFLASG=-O2 # error! >> #export CFLASG=-Ofast # error! >> ./confgure >> make >> >> I am using msys2. > > Incredible as it sounds, in an optimized build, GCC (sometimes?) calls > stpcpy even though the source calls strcpy, provided that the > prototype of stpcpy is in scope. In this case, ntlib.c includes > windows.h, which includes string.h, which comes from lib/string.h, > which declares the prototype of stpcpy, and that is enough to trigger > this misfeature. > > I fixed this by switching the order of the libraries, as suggested, > but only because doing so is TRT in general. Yes, it seems gcc optimizes this because of the following strlen call. You can disable this optimization with -fno-optimize-strlen. -David