This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: isinf
- From: Michael Veksler <VEKSLER at il dot ibm dot com>
- To: Eric Botcazou <ebotcazou at libertysurf dot fr>
- Cc: gcc at gcc dot gnu dot org, Hiroshi Fujishima <hiroshi dot fujishima at gmail dot com>, Joe Buck <Joe dot Buck at synopsys dot com>
- Date: Thu, 14 Jul 2005 10:56:33 +0300
- Subject: Re: isinf
Eric Botcazou <ebotcazou@libertysurf.fr> 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