[LLVMbugs] [Bug 80] C front-end crash on empty structure
bugzilla-daemon at zion.cs.uiuc.edu
bugzilla-daemon at zion.cs.uiuc.edu
Tue Nov 4 11:52:39 PST 2003
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=80
sabre at nondot.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
------- Additional Comments From sabre at nondot.org 2003-11-04 13:52 -------
This is now (re)fixed. Here's a CFE patch:
$ diff -u llvm-types.c~ llvm-types.c
--- llvm-types.c~ 2003-11-02 17:08:38.000000000 -0600
+++ llvm-types.c 2003-11-04 13:25:46.000000000 -0600
@@ -672,7 +672,7 @@
unsigned ElSize = GetDeclSize(field); /* In bits */
int HasSignedField;
unsigned StartByte;
- if (BitAlignment > ElSize) ElSize = BitAlignment;
+ if (ElSize && BitAlignment > ElSize) ElSize = BitAlignment;
HasSignedField = !TREE_UNSIGNED(TREE_TYPE(field));
@@ -1205,15 +1205,25 @@
fprintf(stderr, "Setting field indexes to: { ");
#endif
+ Idx = 0;
for (; Field; Field = GetNextFieldDecl(Field)) {
unsigned FieldByteOffset = GetFieldOffset(Field)/8;
- for (Idx = 0; Idx+1 < Result->NumElements &&
- ElementOffsets[Idx+1] <= FieldByteOffset; ++Idx)
+ for (; Idx+1 < Result->NumElements &&
+ ElementOffsets[Idx+1] <= FieldByteOffset &&
+ ElementOffsets[Idx] != FieldByteOffset; ++Idx)
/*empty*/;
#if DEBUG_STRUCT_LAYOUT
fprintf(stderr, "%d, ", Idx);
#endif
SET_DECL_LLVM(Field, llvm_constant_new_integral(UByteTy, Idx));
+
+ /* If we just passed over a zero sized field, skip ahead to the next
+ * field, so we don't assign all consequtive zero sized elements to the
+ * same field.
+ */
+ if (Idx+1 < Result->NumElements &&
+ ElementOffsets[Idx+1] == ElementOffsets[Idx])
+ ++Idx; /* Start looking at the next field */
}
#if DEBUG_STRUCT_LAYOUT
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list