[llvm-bugs] [Bug 49456] New: Invalid struct offsets generated

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 5 11:20:13 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49456

            Bug ID: 49456
           Summary: Invalid struct offsets generated
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lcampbel at akamai.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Created attachment 24593
  --> https://bugs.llvm.org/attachment.cgi?id=24593&action=edit
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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210305/09e98a58/attachment.html>


More information about the llvm-bugs mailing list