<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - use of overloaded operator '[]' is ambiguous (with template conversion operator)"
   href="https://bugs.llvm.org/show_bug.cgi?id=40610">40610</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>use of overloaded operator '[]' is ambiguous (with template conversion operator)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>chabster@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>#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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>