<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 --- - [-fms-compatibility] Allow ICE pointer values in case labels"
   href="http://llvm.org/bugs/show_bug.cgi?id=16034">16034</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[-fms-compatibility] Allow ICE pointer values in case labels
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>reid.kleckner@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>MSVC accepts this code:

typedef void *HKEY;
#define HKEY_CLASSES_ROOT (( HKEY ) (ULONG_PTR)((LONG)0x80000000) )
...
const wchar_t *HKEYToString(const HKEY key) {
  switch (reinterpret_cast<LONG_PTR>(key)) {
    case HKEY_CLASSES_ROOT:
      return L"HKEY_CLASSES_ROOT";
    case HKEY_CURRENT_CONFIG:
      return L"HKEY_CURRENT_CONFIG";
    case HKEY_CURRENT_USER:
      return L"HKEY_CURRENT_USER";
    case HKEY_LOCAL_MACHINE:
      return L"HKEY_LOCAL_MACHINE";
    case HKEY_USERS:
      return L"HKEY_USERS";
  }
  return L"unknown";
}

It does not accept 'switch (key)', so it must be converting the case label
values to LONG_PTR.

If I try to cast the label values back to LONG_PTR, clang says reinterpret_cast
conversions are not allowed in case labels:

registry.cc:24:10: error: case value is not a constant expression
    case (LONG_PTR)HKEY_USERS:
         ^~~~~~~~~~~~~~~~~~~~
registry.cc:24:10: note: cast that performs the conversions of a
reinterpret_cast is not allowed in a constant expression

It seems the least invasive way to get clang to accept this code is to fall
back to an if/else chain, unless clang adds support for this as an extension.</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>