<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 --- - warn on c-style cast that changes meaning after definition"
   href="http://llvm.org/bugs/show_bug.cgi?id=22181">22181</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>warn on c-style cast that changes meaning after definition
          </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++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nlewycky@google.com
          </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>Testcase from <a href="http://whatofhow.wordpress.com/2014/12/17/evil-casts/">http://whatofhow.wordpress.com/2014/12/17/evil-casts/</a> :

struct S1 { int s1 = 2; };
struct S2;
S2 *f(S1 *s) { return (S2*) s; }
struct T { int t = 1; };
struct S2 : T, S1 {};
int main() { S2 s2; return f(&s2)->t; }

This code builds in -std=c++11 with no interesting warnings. The problem is in
the definition of 'f' which casts to a pointer to incomplete class type. The
std says "It is unspecified whether a static_cast or reinterpret_cast
interpretation is used, even if there is an inheritance relationship between
the two classes."

If we have a C-style cast to a point to an incomplete class type, then when we
see the definition of the class type we should check whether the static_cast
and reinterpret_cast interpretations would have had different semantics.</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>