<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 - Invalid template parameter"
   href="https://bugs.llvm.org/show_bug.cgi?id=42213">42213</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid template parameter
          </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>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>zhonghao@pku.org.cn
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>My clang is 9.0.0, and the code is:


template < bool, class > struct A {};
template < class, int > void f () {};
template < class T, int >
decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};

struct B {};

int main ()

 f < B, 0 >;
 return 0;
}


clang accepts the code, but icc, gcc, and msvc all reject it:

gcc:

<source>:5:56: error: wrong number of template arguments (1, should be 2)

    5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};

      |                                                        ^

<source>:2:33: note: provided for 'template<bool <anonymous>, class> struct A'

    2 | template < bool, class > struct A {};

      |                                 ^

<source>:5:40: error: expected nested-name-specifier before 'A'

    5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};

      |                                        ^

<source>:5:56: error: wrong number of template arguments (1, should be 2)

    5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};

      |                                                        ^

<source>:2:33: note: provided for 'template<bool <anonymous>, class> struct A'

    2 | template < bool, class > struct A {};

      |                                 ^

<source>:5:56: error: wrong number of template arguments (1, should be 2)

    5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};

      |                                                        ^

<source>:2:33: note: provided for 'template<bool <anonymous>, class> struct A'

    2 | template < bool, class > struct A {};

      |                                 ^

<source>:5:56: error: wrong number of template arguments (1, should be 2)

    5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};

      |                                                        ^

<source>:2:33: note: provided for 'template<bool <anonymous>, class> struct A'

    2 | template < bool, class > struct A {};

      |                                 ^

<source>:5:42: error: expected ',' or '...' before '<' token

    5 | decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};

      |                                          ^

Compiler returned: 1

icc:

<source>(5): error: a parameter is not allowed

  decltype (f < T, 1 >) f (T t, typename A < t == 0, int >::type) {};

                                             ^

compilation aborted for <source> (code 2)

Compiler returned: 2

msvc:

example.cpp

<source>(5): error C2975: 'unnamed-parameter': invalid template argument for
'A', expected compile-time constant expression

<source>(2): note: see declaration of 'unnamed-parameter'

<source>(5): error C2039: 'type': is not a member of 'A<false,int>'

<source>(5): note: see declaration of 'A<false,int>'

<source>(5): error C4430: missing type specifier - int assumed. Note: C++ does
not support default-int

<source>(11): warning C4551: function call missing argument list

Compiler returned: 2</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>