<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 - SFINAE does not work properly with type aliases"
   href="https://bugs.llvm.org/show_bug.cgi?id=40242">40242</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SFINAE does not work properly with type aliases
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mingxwa@microsoft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21299" name="attach_21299" title="The code that triggers the bug">attachment 21299</a> <a href="attachment.cgi?id=21299&action=edit" title="The code that triggers the bug">[details]</a></span>
The code that triggers the bug

This bug was found when I was writing traits for some types with `std::void_t`.
Although `std::void_t` is a component in C++17, I have tested some previous
versions of LLVM in C++11 mode with similar code, and the bug also exists.

To trigger the bug, we could simply define a class template which taskes a
default parameter of type `std::void_t<Expressions...>`, for example:

template <class T, class = std::void_t<decltype(std::declval<T>().func())>>
struct my_traits {};

In the code above, `my_traits<T>` shall be an ill-formed expression if
`std::declval<T>().func()` is not well-formed. However, LLVM will treat
`my_traits<T>` as a well-formed expression regardless whether
`std::declval<T>().func()` is well-formed.

To verify this conclusion, we could write another type traits for `my_triats`:

template <class T, class SFINAE = void>
struct has_my_traits : std::false_type {};

template <class T>
struct has_my_traits<T, std::void_t<my_traits<T>>> : std::true_type {};

The following assertion will fire in LLVM, but works fine with GCC or MSVC:

static_assert(!has_my_traits<int>::value, "Oops!");</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>