<div dir="ltr">Rafael,<div><br></div><div>This is a test case. Clang now miscompiles this code. As a result it will print out "i=0 j=1" while it should be "i=1 j=1". Let me roll back this change to fix the issue.<br><div><br></div><div><div>#include <iostream></div><div><br></div><div>static int i = 0;</div><div>static int j = 0;</div><div><br></div><div>class C {</div><div>public:</div><div>  C() { i++; }</div><div>};</div><div><br></div><div>template<typename T></div><div>class D {</div><div>public:</div><div>  D() { j++; }</div><div>  C *f() { return &x; }</div><div>  static C x;</div><div>};</div><div><br></div><div>template<typename T> C D<T>::x;</div><div><br></div><div>int main() {</div><div>  D<void> d;</div><div>  d.f();</div><div>  std::cout << "i=" << i << " j=" << j << "\n";</div><div>}</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 16, 2014 at 3:24 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Previously, relocations applied to .rela.ctors sections in an object file pointed to different .text.startup sections in the same file, but after this patch they point to the same .text.startup section. Because this patch handles section names, it's likely that there's something with that.</div><div><br></div>Sorry for the frequent and incomplete updates. I'll let you know once I get a reproducible test case.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 16, 2014 at 2:43 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>On Thu, Oct 16, 2014 at 2:40 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>> I compared the DSOs built with and without this patch, and found that<br>
> although the size of .ctor sections are the same, the bad DSO contains<br>
> repetition. So some constructors are called more than once (and probably<br>
> some are not called at all). That seems the direct cause of the issue.<br>
><br>
> The test is gigantic and having a lot of dependencies. It takes a little bit<br>
> more time to understand what's going on there.<br>
<br>
</span>Is it open source? I would be more than happy to help reduce it.<br></blockquote><div><br></div></div></div><div>Sorry, no it's not. I'll try to create a minimal test case to reproduce the issue.</div></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>