<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 - Invalid struct offsets generated"
   href="https://bugs.llvm.org/show_bug.cgi?id=49456">49456</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid struct offsets generated
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>lcampbel@akamai.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24593" name="attach_24593" title="Small program demonstrating the bug">attachment 24593</a> <a href="attachment.cgi?id=24593&action=edit" title="Small program demonstrating the bug">[details]</a></span>
Small program demonstrating the bug

The attached Objective-C program, when built with gnustep-base 1.27.0 by clang
6.0.0 and run, demonstrates a bug: although 8 bytes should be allocated for
'id' types, only 4 bytes are allocated. I discovered this in a much larger
program when it segfaulted; I trimmed it down to a minimal test case. 

If you remove any of the instance variables before the problematic one (_id),
the problem goes away.

If you change _enum to a char, the _id ivar gets enough space, but it's
allocated on an odd byte boundary, which is probably wrong.

If you change _enum to a short, _id is allocated only 6 bytes.

If you change _enum to an int, _id is again allocated only 4 bytes.

Compiler flags in all cases (sorry for the verbosity/redundancy, generated by a
build system I have to use):

 -MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNUSTEP_RUNTIME=1
-D_NONFRAGILE_ABI=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing -fexceptions
-fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -pthread -fPIC -Wall -DGSWARN
-DGSDIAGNOSE -Wno-import -Wall -Werror -m64 -march=opteron -mno-3dnow -fPIC
-ggdb -O2 -Wall -fobjc-runtime=gnustep-1.8 -fblocks
-fconstant-string-class=NSConstantString</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>