<html>
    <head>
      <base href="https://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 --- - __builtin_object_size is not consistently conservative with C++ inheritance"
   href="https://llvm.org/bugs/show_bug.cgi?id=26741">26741</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__builtin_object_size is not consistently conservative with C++ inheritance
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>bob.wilson@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=15946" name="attach_15946" title="patch for the object-size.cpp test">attachment 15946</a> <a href="attachment.cgi?id=15946&action=edit" title="patch for the object-size.cpp test">[details]</a></span>
patch for the object-size.cpp test

Clang r250488 added code to make __builtin_object_size more conservative when
dealing with an array of size 0 or 1 as the last member in a struct to support
the "writing off the end" idiom. The CodeGen/object-size.cpp test was added
along with that patch. I noticed that if I change the test2() function in that
test to use a buffer size of 1, then it does not report the object size in the
same conservative way. It didn't look like that was intentional. The
isDesignatorAtObjectEnd() function in lib/AST/ExprConstant.cpp is not handling
the case with C++ inheritance and so it gives up. The catch is that "giving up"
in this case does not lead to the conservative behavior. The attached patch to
the test shows what I would expect to happen.</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>