Roland McGrath, le Tue 10 Oct 2006 00:16:25 -0700, a écrit :
> > Roland, what do you prefer? Based on that I will then send in patches
> > also for the other *utimes.c files, which have similar problems, as the
> > code looks like.
>
> I haven't figured out what you think this is fixing.
Glibc is compiled with -fstrict-aliasing, and hence casts like
*(time_value_t*)&tvp[0]
don't propagate the "value is used" property, according to
strict C aliasing rules. As a result, the
timevals[1].tv_usec = timevals[0].tv_usec = (time_t)-1;
statement is just optimized out! See attached program that reproduces
the behavior of futimes. Before 4.0, gcc was not able to optimize such
cases, but now it is.
Another solution would of course be to compile glibc with
-fno-strict-aliasing, but that will probably prevent a bunch of
optimizations.
Samuel
#include "test2.h"
struct a {
int a;
int b;
};
void f(const struct a a[2]) {
struct a _a[2];
if (!go) {
_a[0].a = 5;
_a[0].b = 6;
_a[1].a = 7;
_a[1].b = 8;
a = _a;
}
print(*(struct foo*)&a[0]);
print(*(struct foo*)&a[1]);
}
int main(void) {
struct a a[2] = { { 1, 2 }, { 3, 4 } };
f(a);
return 0;
}
#include <stdio.h>
#include "test2.h"
int go;
void print(struct foo foo) {
printf("%d %d\n",foo.a1,foo.a2);
}
struct foo {
int a1;
int a2;
};
extern int go;
void print(struct foo foo);
_______________________________________________
Bug-hurd mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-hurd