Re: type-punning warnings with optimizations turned on?



jcupitt gmail com wrote:

On 7/6/07, Ernie Wright <erniew comcast net> wrote:

> (now someone will tell me the compiler is correct and casting "int
> *x[]" to "void **" is indeed wrong :-)

This is question 4.9 in the C FAQ:

    http://c-faq.com/ptrs/genericpp.html


That's very interesting, thank you. Does that mean that (void **)
((void *) x) fixes the problem correctly? Or do you need a real
intermediate variable?

That may depend on what you mean by "correctly."  :)

Someone smarter than I should be consulted, but I believe that the
intermediate cast works exactly as if a temp variable were involved.

Or, looking at "correctly" differently, it's OK to cast away the warning
on systems for which all pointers have the same representation.

See also

   http://groups.google.com/group/comp.lang.c/msg/42f0898e5500d015?hl=en

- Ernie                                  http://home.comcast.net/~erniew



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