<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 - Clang 5.0 consider template method unevaluated and accepts this code, GCC rejects it"
   href="https://bugs.llvm.org/show_bug.cgi?id=34009">34009</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang 5.0 consider template method unevaluated and accepts this code, GCC rejects it
          </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++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>joker.eph@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang accepts the following (C++11) code while GCC rejects it (4.9 to 7.0).
Clang seems to consider that the constexpr `IS_N` is enough to make the method
`bar()` unevaluated, while gcc complains. I don't understand what makes clang
happy here?

Changing the define makes both compiler happy, as the constexpr is dependent on
the template args.



#include <type_traits>

#define INDEPENDENT_CONSTEXPR 1

template<int N = 1>
struct Bar {
  typename std::enable_if<N != 1, void>::type foo() {
  }
};

template<int N = 1>
struct Foo {
#if INDEPENDENT_CONSTEXPR
    static constexpr bool IS_N = true;
#else 
    static constexpr bool IS_N = (N == 1);
#endif
    // (N == 1);
    using myBar = Bar<IS_N>;

    void bar() {
        myBar b;
        b.foo();
    }
};


void foobar() {
  Foo<0> f0;
  Foo<1> f1;
#if !INDEPENDENT_CONSTEXPR
  f0.bar();
#endif
// Following should never work
//  f1.bar();
}</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>