> and I can't get it to produce invalid code. The main difference is
> that without a static constructor there is never an always run piece
> of code that assumes that it has to write to y. We also put y in a rw
> section even when S::x is defined, but I think that is a bug (and will
> report it in a sec).
Never mind, a better testcase is
struct S {
static const int x;
};
//const int S::x = 42;
inline const int* f() {
static const int y = S::x;
return &y;
}
const int *g() { return f(); }
With the S::x definition comment we put _ZZ1fvE1y in .bss. With the
definition present, it is placed in .rodata._ZZ1fvE1y. I guess it is
theoretically possible for a linker to pick _ZZ1fvE1y from one file
and _Z1fv from another, producing an invalid result.
I will try to write a patch putting the variable and gv in the same
comdat as the inline function.
Cheers,
Rafael
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits