From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Using stpcpy Date: Sat, 27 Dec 2014 21:52:20 +0200 Message-ID: <83bnmolvkb.fsf@gnu.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> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1419709971 7405 80.91.229.3 (27 Dec 2014 19:52:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 27 Dec 2014 19:52:51 +0000 (UTC) Cc: emacs-devel@gnu.org To: chengang31@gmail.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 27 20:52:43 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 1Y4xPn-0008Ie-Je for ged-emacs-devel@m.gmane.org; Sat, 27 Dec 2014 20:52:43 +0100 Original-Received: from localhost ([::1]:56774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y4xPm-00019P-PS for ged-emacs-devel@m.gmane.org; Sat, 27 Dec 2014 14:52:42 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y4xPj-00019I-Jz for emacs-devel@gnu.org; Sat, 27 Dec 2014 14:52:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y4xPe-0001JF-Jm for emacs-devel@gnu.org; Sat, 27 Dec 2014 14:52:39 -0500 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:61565) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y4xPe-0001J0-BS for emacs-devel@gnu.org; Sat, 27 Dec 2014 14:52:34 -0500 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NH900E00ANB9B00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Sat, 27 Dec 2014 21:52:32 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NH900EQYB7K1L30@a-mtaout22.012.net.il>; Sat, 27 Dec 2014 21:52:32 +0200 (IST) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.172 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:180719 Archived-At: > 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. Thanks.