[llvm-bugs] [Bug 40610] New: use of overloaded operator '[]' is ambiguous (with template conversion operator)
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 5 08:41:30 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40610
Bug ID: 40610
Summary: use of overloaded operator '[]' is ambiguous (with
template conversion operator)
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: chabster at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
neeilans at live.com, richard-llvm at metafoo.co.uk
#include <type_traits>
struct abc
{
operator bool *() { return {}; }
template <typename T> operator T *() { return {}; }
//template <typename T, typename U = std::enable_if_t<std::is_same_v<T,
std::remove_cv_t<T>>> > operator T *() = delete;
};
int main() {
abc{}[0];
return 0;
}
#1 with x86-64 clang 7.0.0
<source>:11:10: error: use of overloaded operator '[]' is ambiguous (with
operand types 'abc' and 'int')
abc{}[0];
~~~~~^~
<source>:11:10: note: built-in candidate operator[](_Bool *, long)
<source>:11:10: note: built-in candidate operator[](const _Bool *, long)
<source>:11:10: note: built-in candidate operator[](volatile _Bool *, long)
<source>:11:10: note: built-in candidate operator[](const volatile _Bool *,
long)
If second template is used instead - it compiles just fine.
GCC, MSVC and ICC all are happy with this code.
--
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/20190205/6ea7e8c5/attachment.html>
More information about the llvm-bugs
mailing list