Orion Poplawski wrote:
> When compiled with -O2 and gcc 4.0.2 or 4.1.0 on x86_64, lam_int_pos()
> returns the incorrect result. This breaks MPI_Attr_get() when called
> from Fortran (and was detected in the 7.1.2 test suite by attrsetget_f).
> I've filed a bug with gcc here
> <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27744>, but in the meantime
> I've just hacked lam_int_pos() to return 0, which is the correct result
> on x86_64. I haven't tested with other versions of gcc, but suspect
> this may have come in with 4.0.
>
Here's the response from the gcc folks:
---
This code accesses v, which is of type void*, via an lvalue of type int.
This is not allowed by C aliasing rules. Use -fno-strict-aliasing or a
union to express this operation.
---
So perhaps lam_int_pos should be:
union {
void *voidval;
int intval;
} v;
v.voidval = (void*) 1;
int *i = &v.intval;
if (intpos != -1)
return intpos;
for (intpos = 0; intpos < (sizeof(void*) / sizeof(int)); intpos++)
if (i[intpos] == 1)
break;
return intpos;
which is more like the code in f77/attrget_f.c.
--
Orion Poplawski
System Administrator 303-415-9701 x222
Colorado Research Associates/NWRA FAX: 303-415-9702
3380 Mitchell Lane, Boulder CO 80301 http://www.co-ra.com
|