| Issue |
161511
|
| Summary |
[clang][RecordLayoutBuilder] Inconsistent packing of _BitInt bit-fields with the same underlying size
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
KennethHilmersson
|
Due to an overflow in
unsigned char LastBitfieldStorageUnitSize;
in ItaniumRecordLayoutBuilder there could be wrong packing of ms-bitfields.
When the storage size 256 is stored in LastBitfieldStorageUnitSize this will be zero and a new type is opened for storage of the next field.
[godbolt](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:36,endLineNumber:8,positionColumn:36,positionLineNumber:8,selectionStartColumn:36,selectionStartLineNumber:8,startColumn:36,startLineNumber:8),source:'%23pragma+ms_struct+on%0A%0A//+Error!!+struct+a+will+be+layout+in+two+i256%0A//+Due+to+an+overflow+in%0A//+unsigned+char+LastBitfieldStorageUnitSize%3B%0A//+in+ItaniumRecordLayoutBuilder%0A//+when+storage+size+256+is+assigned+-%3E+zero.%0A//+f3+will+be+packed+in+a+new+i256:%0Astruct+%7B+_BitInt(250)+f2+:+2%3B++_BitInt(250)+f3+:+2%3B+%7D+__attribute__((packed,+aligned(1)))+a%3B%0A%0A//+Ok!!+f2+and+f3+are+packed+in+the+same+type:%0Astruct+%7B+_BitInt(192)+f2+:+2%3B++_BitInt(192)+f3+:+2%3B+%7D+__attribute__((packed,+aligned(1)))+b%3B%0A%0A//+Ok!!+f2+and+f3+are+packed+in+the+same+type:%0Astruct+%7B+_BitInt(128)+f2+:+64%3B++_BitInt(128)+f3+:+64%3B+%7D+__attribute__((packed,+aligned(1)))+c%3B'),l:'5',n:'0',o:'C+source+%231',t:'0')),k:38.112094395280245,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:cclang1910,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'0',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:2,lang:___c,libs:!(),options:'+-Xclang+-fms-extensions+-Xclang+-fdump-record-layouts+',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+19.1.0+(Editor+%231)',t:'0')),k:13.416259256967223,l:'4',m:100,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:2,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+19.1.0+(Compiler+%232)',t:'0')),k:48.47164634775255,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs