[cfe-dev] Clang: Erroneous behavior on windows

David Majnemer david.majnemer at gmail.com
Sun Mar 22 14:44:00 PDT 2015


On Sun, Mar 22, 2015 at 10:25 AM, Daniel Berenyi <u235axe at gmail.com> wrote:

> 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?
>

Seems OK on 64-bit targets but fails for targets which have distinct
cdecl/thiscall calling conventions like 32-bit mingw and 32-bit msvc.

Reid, any ideas?


>
> Thanks in advance,
> Daniel
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150322/f37516cb/attachment.html>


More information about the cfe-dev mailing list