<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 candidate function for unary operator on scoped enum"
   href="http://llvm.org/bugs/show_bug.cgi?id=19452">19452</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid candidate function for unary operator on scoped enum
          </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>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>zilla@kayari.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang accepts this, recent versions of G++ reject it:

struct D
{
  template <class T> D (T);
};
int operator~(const D &);

template <typename T> T &make ();

template <typename Rhs> struct H
{
  static const int value = sizeof ~make<Rhs>();
};

enum class E;

int main () { return H<E>::value; }


Both clang and G++ reject:

  static const int value = sizeof ~make<E>();

Whereas clang accepts (and G++ rejects) the same expression using a dependent
type:

template <typename Rhs> struct H
{
  static const int value = sizeof ~make<Rhs>();
};

Clang constructs a temporary of type D and applies operator~ to that temporary.

This was first reported to <a href="http://gcc.gnu.org/PR60852">http://gcc.gnu.org/PR60852</a> but closed for the
reasons given at <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60852#c13">http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60852#c13</a> i.e.
[over.match.oper]/3, so either we're wrong or clang is :)</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>