[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using stpcpy
From: |
David Engster |
Subject: |
Re: Using stpcpy |
Date: |
Sat, 27 Dec 2014 21:03:10 +0100 |
User-agent: |
Gnus/5.13001 (Ma Gnus v0.10) Emacs/24.3.91 (gnu/linux) |
Eli Zaretskii writes:
>> From: cg <address@hidden>
>> 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
- Re: Using stpcpy, (continued)
- Re: Using stpcpy, Dani Moncayo, 2014/12/26
- Re: Using stpcpy, Eli Zaretskii, 2014/12/26
- Re: Using stpcpy, Dani Moncayo, 2014/12/26
- Re: Using stpcpy, cg, 2014/12/27
- Re: Using stpcpy, Eli Zaretskii, 2014/12/27
- Re: Using stpcpy, Dani Moncayo, 2014/12/27
- Re: Using stpcpy, Eli Zaretskii, 2014/12/27
- Re: Using stpcpy, Dani Moncayo, 2014/12/27
- Re: Using stpcpy, cg, 2014/12/27
- Re: Using stpcpy, Eli Zaretskii, 2014/12/27
- Re: Using stpcpy,
David Engster <=
- Re: Using stpcpy, Eli Zaretskii, 2014/12/27
- Re: Using stpcpy, Eli Zaretskii, 2014/12/27
- Re: Using stpcpy, David Engster, 2014/12/27
- Re: Using stpcpy, Eli Zaretskii, 2014/12/27
- Re: Using stpcpy, Richard Stallman, 2014/12/28