This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

strict aliasing problem?


Hi,
 
I'm using GCC 4.4.1 on an MPC5200 target and I was getting incorrect
results from:
  libm/current/src/double/ieee754-core/e_exp.c

Once I pass -fno-strict-aliasing to the math library, everything works
fine.  (On a side note, everything works fine either way with GCC 3.3)
 
It looks like e_exp.c accesses the double "x" through CYG_LIBM_HI():
  #define CYG_LIBM_HI(__x)  (((Cyg_libm_ieee_double_shape_type
*)&__x)->parts.msw)
where Cyg_libm_ieee_double_shape_type is a union type.
 
According to:
 
http://gcc.gnu.org/onlinedocs/gcc-4.4.4/gcc/Optimize-Options.html#index-
fstrict_002daliasing-750
code such as the following results in undefined behavior:
  union a_union {
    int i;
    double d;
  };
  int f() {
    double d = 3.0;
    return ((union a_union *) &d)->i;
  }

Should all targets use -fno-strict-aliasing when building the math
library for safety?

Thanks,
Will

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]