Fix struct packing for VCC. (#7049)
"#pragma pack(1)" sets current alligment without pushing into stack, so "#pragma pack(pop)" causing stack underflow.
This commit is contained in:
parent
e7e37713dd
commit
a54430ea2d
1 changed files with 2 additions and 2 deletions
|
|
@ -496,7 +496,7 @@ proc genRecordFieldsAux(m: BModule, n: PNode,
|
||||||
if hasAttribute in CC[cCompiler].props:
|
if hasAttribute in CC[cCompiler].props:
|
||||||
add(unionBody, "struct __attribute__((__packed__)){" )
|
add(unionBody, "struct __attribute__((__packed__)){" )
|
||||||
else:
|
else:
|
||||||
addf(unionBody, "#pragma pack(1)$nstruct{", [])
|
addf(unionBody, "#pragma pack(push, 1)$nstruct{", [])
|
||||||
add(unionBody, a)
|
add(unionBody, a)
|
||||||
addf(unionBody, "} $1;$n", [sname])
|
addf(unionBody, "} $1;$n", [sname])
|
||||||
if tfPacked in rectype.flags and hasAttribute notin CC[cCompiler].props:
|
if tfPacked in rectype.flags and hasAttribute notin CC[cCompiler].props:
|
||||||
|
|
@ -551,7 +551,7 @@ proc getRecordDesc(m: BModule, typ: PType, name: Rope,
|
||||||
if hasAttribute in CC[cCompiler].props:
|
if hasAttribute in CC[cCompiler].props:
|
||||||
result = structOrUnion(typ) & " __attribute__((__packed__))"
|
result = structOrUnion(typ) & " __attribute__((__packed__))"
|
||||||
else:
|
else:
|
||||||
result = "#pragma pack(1)" & tnl & structOrUnion(typ)
|
result = "#pragma pack(push, 1)" & tnl & structOrUnion(typ)
|
||||||
else:
|
else:
|
||||||
result = structOrUnion(typ)
|
result = structOrUnion(typ)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue