[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: arm gcc 4.1.3 -O2 dead code removal breaks configure test

From: Andrew W. Nosenko
Subject: Re: arm gcc 4.1.3 -O2 dead code removal breaks configure test
Date: Wed, 30 Mar 2011 03:01:45 +0300

On Tue, Mar 29, 2011 at 20:18, Ralf Wildenhues <address@hidden> wrote:
> Hello Dave,
> * Dave Hart wrote on Tue, Mar 29, 2011 at 11:58:53AM CEST:
>>               struct in6_addr in6;
>>               in6 = in6addr_any;
>> and the optimizer (quite rightly) noticed the value of in6 goes out of
>> scope without being referenced again and eliminated the assignment,
>> thereby eliminating all references to in6addr_any, undermining the
>> intent of the test.
> [...]
>> We have a solution, changing the test to assign the address of
>> in6addr_any to a global variable preserves the reference:
>> struct in6_addr * pin6addr_any = &in6addr_any;
>> int main() {
>>     return 0;
>> }
> [...]
>> Is our fix the best you can imagine?
> In order to be absolutely sure that the compiler can't optimize away the
> reference, I'd say you need to modify external state depending on it.
> Typically, you can do that by printing its contents, or, if those aren't
> well-defined (so the compiler might warn about that), its address (with
> %lu and cast to unsigned long, for portability).  Of course this means
> the test needs to include AC_INCLUDES_DEFAULT in the test header, for
> stdio.h.  The latter means you can then drop including sys/types another
> time.

IMHO, better would to be just disable a compiler to do optimization
dances around 'in6' variable (i.e. mark 'in6' as 'volatile'):

               volatile struct in6_addr in6;
               in6 = in6addr_any;

Andrew W. Nosenko <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]