<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 - -Wcast-qual should not warn about dropping 'const' when casting to ObjC types"
   href="https://bugs.llvm.org/show_bug.cgi?id=33929">33929</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Wcast-qual should not warn about dropping 'const' when casting to ObjC types
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>jordan_rose@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>// clang -fsyntax-only -x objective-c -Weverything -
id reinterpretAsObject(const void *ptr) {
  return (id)ptr;
}

<stdin>:2:14: warning: cast from 'const void *' to 'id' drops const qualifier
      [-Wcast-qual]
  return (id)ptr;
             ^

...however, there's no way to avoid this warning; you can't const-qualify
Objective-C object types inside the pointer. It might have been better if this
weren't a common idiom on Apple platforms, but it is---both 'const void *' and
opaque pointers to const struct types are sometimes valid Objective-C objects,
and casts to 'id', 'Class', or concrete object pointer types like 'NSString *'
are considered common and acceptable.

(If we /were/ to start warning on these all the time, they should be silenced
by adding '__bridge', and the warning should have a fix-it. But even that's
probably too much churn for Apple platforms.)</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>