[llvm-bugs] [Bug 30262] New: user-defined operators are not called on lambda

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 2 12:40:55 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30262

            Bug ID: 30262
           Summary: user-defined operators are not called on lambda
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mikhail.strelnikov at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Following code prints "clang" when compiled with clang and prints "gcc or msvc"
when compiled with gcc or msvc.

#include <iostream>

namespace other
{
    template<typename F>
    void bar(F && f)
    {
        (*(&f))();
    }
}

namespace n
{
    template<typename>
    struct o {  };
    template<typename>
    struct p { void operator()(){ std::cout << "gcc or msvc" << std::endl; } };

    template<typename T>
    constexpr auto operator&(T)
    {
        return o<T>{};
    }
    template<typename T>
    constexpr auto operator*(T)
    {
        return p<T>{};
    }

    void foo()
    {
        other::bar([](){ std::cout << "clang" << std::endl; });
    }
}

int main()
{
    n::foo();
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160902/74a16572/attachment.html>


More information about the llvm-bugs mailing list