[llvm-bugs] [Bug 33179] New: failed look-up for explicit conversion operator with type deduction

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 26 06:11:06 PDT 2017


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

            Bug ID: 33179
           Summary: failed look-up for explicit conversion operator with
                    type deduction
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eduard at valeyev.net
                CC: llvm-bugs at lists.llvm.org

This fails to compile with all clang++ versions unless
DISABLE_EXPLICIT_OPERATOR_AUTO is #defined. GNU and Intel frontends do not
suffer from this issue.

#include <iostream>

template <typename T>
struct A {
  A(T v) : value(v) {}
  T value;
};

template <typename T, typename Op>
struct B {
  B(T v, Op op = Op()) : value(v), op(op) {}
#ifndef DISABLE_EXPLICIT_OPERATOR_AUTO
  explicit
#endif
  operator auto() const { return op(this->value); }
  Op op;
  T value;
};

template <typename T>
struct Convert {
  A<T> operator()(T v) const {
    return A<T>(v + 1);
  }
};


int main() {
  B<int, Convert<int>> b(1);
  A<int> a = static_cast<A<int>>(b);
  std::cout << a.value << std::endl;
  return 0;
}

-- 
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/20170526/f19cc923/attachment.html>


More information about the llvm-bugs mailing list