autoconf
[Top][All Lists]
Advanced

[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: Ralf Wildenhues
Subject: Re: arm gcc 4.1.3 -O2 dead code removal breaks configure test
Date: Tue, 29 Mar 2011 19:18:07 +0200
User-agent: Mutt/1.5.20 (2010-08-04)

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.

Hope that helps.

Cheers,
Ralf



reply via email to

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