<br><br><div class="gmail_quote">On Tue, Feb 19, 2013 at 7:15 PM, Olivier Goffart <span dir="ltr"><<a href="mailto:ogoffart@kde.org" target="_blank">ogoffart@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tuesday 19 February 2013 18:51:16 Laszlo Nagy wrote:<br>
> Hi All,<br>
><br>
> I'm trying to compile a C++ project with Clang. It compiles with gcc<br>
> without error, but Clang breaks. Unfortunately could not simplify further<br>
> and has 'boost' as dependency. I need some help.<br>
><br>
> How can I change the code to compile with clang? And if it is a not<br>
> expected behavior of Clang, what could be an error report for this?<br>
><br>
> Thanks,<br>
> Laszlo<br>
><br>
<br>
I reduced your testcase:<br>
<br>
   template <typename T> void ref(T &) { return 8; }<br>
   struct S { int foo() { return ref(this); } };<br>
<br>
I think it is GCC being wrong there.  You should not be able to take a<br>
reference from 'this'.<br>
<br>
You can try boost::cref,  or something like<br>
  S *that = this; ... boost::ref(that)<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br>It's always arguable what the "type" of `this` is, seeing as it's an artifact, but seeing as you cannot reasonable mutate `this` itself (the pointer, not the pointee), I always think about it as being `T* const`.<br>
<br>-- Matthieu<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
--<br>
Olivier<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</font></span></blockquote></div><br>