sizealign of union type (#10780)
* sizealign of union type * add error message for packed union
This commit is contained in:
parent
ebe0473511
commit
1d9b88f25d
2 changed files with 62 additions and 4 deletions
|
|
@ -401,7 +401,7 @@ assert sizeof(Bar) == 12
|
|||
type
|
||||
A = int8 # change to int16 and get sizeof(C)==6
|
||||
B = int16
|
||||
C = object {.packed.}
|
||||
C {.packed.} = object
|
||||
d {.bitsize: 1.}: A
|
||||
e {.bitsize: 7.}: A
|
||||
f {.bitsize: 16.}: B
|
||||
|
|
@ -410,7 +410,7 @@ assert sizeof(C) == 3
|
|||
|
||||
|
||||
type
|
||||
MixedBitsize = object {.packed.}
|
||||
MixedBitsize {.packed.} = object
|
||||
a: uint32
|
||||
b {.bitsize: 8.}: uint8
|
||||
c {.bitsize: 1.}: uint8
|
||||
|
|
@ -420,6 +420,14 @@ type
|
|||
|
||||
doAssert sizeof(MixedBitsize) == 12
|
||||
|
||||
|
||||
type
|
||||
MyUnionType {.union.} = object
|
||||
a: int32
|
||||
b: float32
|
||||
|
||||
doAssert sizeof(MyUnionType) == 4
|
||||
|
||||
##########################################
|
||||
# bug #9794
|
||||
##########################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue