r218141 - In the Itanium ABI, move stuff to the comdat of variables with static init.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Sat Nov 1 11:05:08 PDT 2014


> 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



More information about the cfe-commits mailing list