[cfe-dev] Clang: Erroneous behavior on windows

Daniel Berenyi u235axe at gmail.com
Sun Mar 22 10:25:23 PDT 2015


Dear All,

I'm using clang on windows under Visual Studio 2015 CTP 6. I've tried both
the official binaries: http://llvm.org/releases/download.html, and this
one: http://sourceforge.net/projects/clangonwin/postdownload?source=dlp ,
and with all of them the following code fails to compile for me, but it is
expected to be correct (based on stackoverflow), and it does comile with
VS, and both clang and gcc on http://gcc.godbolt.org/

The code is the following, its is compiled with the additional flag:
-Xclang -std=c++14

//-----------------------------------------------
template<typename F>
  decltype(auto) deduce(F f){ return &decltype(f)::operator(); }

template<typename C, typename R, typename A> decltype(auto)
  signaturehelper( R(C::*f)(A)const ) { return R(); }

int main()
{
  auto l = [](int x){return x*2;};
  decltype(signaturehelper(deduce(l))) p;
}
//--------------------------------

It fails with:
decltype(signaturehelper(deduce(l))) p;
               ^~~~~~~~~~~~~~~
note: candidate template ignored: substitution failure [with C = (lambda at
main.cpp:9:11), R = float, A = int]
decltype(auto) signaturehelper(R(C::*f)(A)const) { return R(); }

Other workarounds show that the compiler believes that the lambda has no
member ::operator().

Am I overlooking something, or there is some problem with some settings /
flags or the Windows build?

Thanks in advance,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150322/072e2688/attachment.html>


More information about the cfe-dev mailing list