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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to