Eric Botcazou <[EMAIL PROTECTED]> wrote on 14/07/2005 10:05:50:
[...]
> union U {
> int i;
> double d;
> };
>
> volatile int a;
>
> int
> main (int argc, char *argv[])
> {
> union U u;
> u.i = argc;
> a = isinf (u.d);
> return 0;
> }
>
Doesn't the code display undefined behavior when sizeof(u.i)<sizeof(u.d) ?
Not all of u.d will be initialized by u.i = argc, accessing the
uninitialized bits of u.d may trigger undefined behavior.
Maybe there is a simpler way? For example:
volatile int a;
volatile double b;
int main ()
{
a = isinf (b);
return 0;
}
This way the compiler must not assume anything about 'b',
making it impossible to optimizes the call to isinf.
Michael