[llvm-bugs] [Bug 36131] New: error: use of overloaded operator '*' is ambiguous

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jan 28 18:02:48 PST 2018


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

            Bug ID: 36131
           Summary: error: use of overloaded operator '*' is ambiguous
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: stsp at list.ru
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Created attachment 19762
  --> https://bugs.llvm.org/attachment.cgi?id=19762&action=edit
test-case

The following code compiles with g++ but not clang++:
---
class A {
    char a;
public:
    operator char *() { return &a; }
    template<typename T0>
    operator T0 *() { return &a; }
};

int main()
{
    A a;
    return *a;
}
---
$ clang++ overl.cpp 
overl.cpp:12:12: error: use of overloaded operator '*' is ambiguous
      (operand type 'A')
    return *a;
           ^~
overl.cpp:12:12: note: built-in candidate operator*(char *)
overl.cpp:12:12: note: built-in candidate operator*(const char *)
---

Initially I thought this may be a gcc bug.
This code is probably invalid.
But the interesting thing is that if I change
"T0" to "const char" in line 6 leaving line 5
untouched, then clang++ compiles it. I don't
think something should change if I change the
templated type to explicit type, so I think
this is a clang's bug.

-- 
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/20180129/518ee650/attachment.html>


More information about the llvm-bugs mailing list