<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 evaluation for functions fails inside std::enable_if"
   href="https://bugs.llvm.org/show_bug.cgi?id=37159">37159</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Default argument evaluation for functions fails inside std::enable_if
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </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>C++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>attila.krasznahorkay@cern.ch
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20194" name="attach_20194" title="Source file demonstrating the issue">attachment 20194</a> <a href="attachment.cgi?id=20194&action=edit" title="Source file demonstrating the issue">[details]</a></span>
Source file demonstrating the issue

Hi,

I've come across the following very recently, while trying to build a fairly
convoluted piece of code on MacOS, with Apple's clang 9.1 version. And then
checked that the exact same issue shows up with all versions of clang on Linux
that I could get my hands on. (3.9.1, 5.0.1, 6.0.0)

The issue is demonstrated by the attached, very synthetic and not too
meaningful example. (The setup in which I first saw this was a bit more
complicated...) When trying to compile the file in C++11 mode or higher, I get
the following build error from clang:

defaultArgProblem.cxx:14:29: error: use of default argument to function
'function1' that is declared later in class
      'TestClass'
   typename std::enable_if< function1(), int >::type function2() {
                            ^
defaultArgProblem.cxx:11:45: note: default argument declared here
   static constexpr bool function1( int i = 1 ) { return i == number; }
                                            ^
defaultArgProblem.cxx:14:49: error: non-friend class member 'type' cannot have
a qualified name
   typename std::enable_if< function1(), int >::type function2() {
                                              ~~^
defaultArgProblem.cxx:14:53: error: expected ';' at end of declaration list
   typename std::enable_if< function1(), int >::type function2() {
                                                    ^
                                                    ;
3 errors generated.

While I'm able to compile the same source file with all the other compilers I
tried. (gcc-6.2.0, gcc-7.2.0 and icc-2018.)

Since nobody around me was aware of this issue previously, I thought it may be
useful to let you guys know about it. Of course we could work our way around
this, simply introducing an overload of the function in our original code that
receives no arguments. So it's by no means a serious problem for us. Still,
understanding it may be useful for the future.

Cheers,
      Attila</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>