<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 - Default argument of constexpr functions not usable in template using?"
   href="https://bugs.llvm.org/show_bug.cgi?id=48222">48222</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Default argument of constexpr functions not usable in template using?
          </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>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>lf-bt@thax.hardliners.org
          </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>See the following code. 
The error message is not helpful, either: the default argument is declared
earlier, and when given explicitly (-> workaround) the compiler has no
problems.

--- also <a href="https://godbolt.org/z/1b7h6b">https://godbolt.org/z/1b7h6b</a> :

struct foo {
  static constexpr int max(int idx, int min = 0) {
    return (idx > min) ? idx : min;
  }

  template <int I>
  using slice = decltype(max(I)); // fails only in clang
//  using slice = decltype(max(2));  // also fails in gcc trunk, but not gcc
10.2
//  using slice = decltype(max(2, 0));  // workaround
};

---

<source>:7:26: error: use of default argument to function 'max' that is
declared later in class 'foo'
  using slice = decltype(max(I)); // fails only in clang
                         ^
<source>:2:47: note: default argument declared here
  static constexpr int max(int idx, int min = 0) {
                                              ^</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>