URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 154 |
Rev 816 |
// Test that type punning using an anonymous union works with strict aliasing.
|
// Test that type punning using an anonymous union works with strict aliasing.
|
// { dg-do run }
|
// { dg-do run }
|
// { dg-options "-O2 -fstrict-aliasing" }
|
// { dg-options "-O2 -fstrict-aliasing" }
|
|
|
extern "C" void abort ();
|
extern "C" void abort ();
|
|
|
void f (long i)
|
void f (long i)
|
{
|
{
|
union
|
union
|
{
|
{
|
long ui;
|
long ui;
|
float uf[20];
|
float uf[20];
|
};
|
};
|
|
|
ui = i;
|
ui = i;
|
if (uf[0] != 42.0)
|
if (uf[0] != 42.0)
|
abort ();
|
abort ();
|
}
|
}
|
|
|
int main ()
|
int main ()
|
{
|
{
|
union U { long i; float f[20]; } u;
|
union U { long i; float f[20]; } u;
|
u.f[0] = 42.0;
|
u.f[0] = 42.0;
|
f (u.i);
|
f (u.i);
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.