<p dir="ltr">Thanks, that sounds ideal.</p>
<div class="gmail_quote">On 1 Nov 2014 11:06, "Rafael Espíndola" <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> and I can't get it to produce invalid code. The main difference is<br>
> that without a static constructor there is never an always run piece<br>
> of code that assumes that it has to write to y. We also put y in a rw<br>
> section even when S::x is defined, but I think that is a bug (and will<br>
> report it in a sec).<br>
<br>
Never mind, a better testcase is<br>
<br>
struct S {<br>
  static const int x;<br>
};<br>
//const int S::x = 42;<br>
inline const int* f() {<br>
  static const int y = S::x;<br>
  return &y;<br>
}<br>
const int *g() { return f(); }<br>
<br>
<br>
With the S::x definition comment we put _ZZ1fvE1y in .bss. With the<br>
definition present, it is placed in .rodata._ZZ1fvE1y. I guess it is<br>
theoretically possible for a linker to pick _ZZ1fvE1y from one file<br>
and _Z1fv from another, producing an invalid result.<br>
<br>
I will try to write a patch putting the variable and gv in the same<br>
comdat as the inline function.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div>