From cfe-dev Tue Feb 19 18:15:20 2013 From: Olivier Goffart Date: Tue, 19 Feb 2013 18:15:20 +0000 To: cfe-dev Subject: Re: [cfe-dev] boost::ref issue Message-Id: <3754411.9bF76J3YC6 () gargamel> X-MARC-Message: https://marc.info/?l=cfe-dev&m=136129800725334 On Tuesday 19 February 2013 18:51:16 Laszlo Nagy wrote: > Hi All, > > I'm trying to compile a C++ project with Clang. It compiles with gcc > without error, but Clang breaks. Unfortunately could not simplify further > and has 'boost' as dependency. I need some help. > > How can I change the code to compile with clang? And if it is a not > expected behavior of Clang, what could be an error report for this? > > Thanks, > Laszlo > I reduced your testcase: template void ref(T &) { return 8; } struct S { int foo() { return ref(this); } }; I think it is GCC being wrong there. You should not be able to take a reference from 'this'. You can try boost::cref, or something like S *that = this; ... boost::ref(that) -- Olivier _______________________________________________ cfe-dev mailing list cfe-dev@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev