* fixes #20914; fixes the align of bug sets * add a test for alignof
This commit is contained in:
parent
2709898a5e
commit
b57a9637e8
2 changed files with 31 additions and 2 deletions
|
|
@ -319,10 +319,10 @@ proc computeSizeAlign(conf: ConfigRef; typ: PType) =
|
||||||
typ.align = int16(conf.floatInt64Align)
|
typ.align = int16(conf.floatInt64Align)
|
||||||
elif align(length, 8) mod 8 == 0:
|
elif align(length, 8) mod 8 == 0:
|
||||||
typ.size = align(length, 8) div 8
|
typ.size = align(length, 8) div 8
|
||||||
typ.align = int16(conf.floatInt64Align)
|
typ.align = 1
|
||||||
else:
|
else:
|
||||||
typ.size = align(length, 8) div 8 + 1
|
typ.size = align(length, 8) div 8 + 1
|
||||||
typ.align = int16(conf.floatInt64Align)
|
typ.align = 1
|
||||||
of tyRange:
|
of tyRange:
|
||||||
computeSizeAlign(conf, typ[0])
|
computeSizeAlign(conf, typ[0])
|
||||||
typ.size = typ[0].size
|
typ.size = typ[0].size
|
||||||
|
|
|
||||||
|
|
@ -27,3 +27,32 @@ type
|
||||||
|
|
||||||
static:
|
static:
|
||||||
doAssert(compiles(offsetOf(Payload, vals)))
|
doAssert(compiles(offsetOf(Payload, vals)))
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
GoodboySave* {.bycopy.} = object
|
||||||
|
saveCount: uint8
|
||||||
|
savePoint: uint16
|
||||||
|
shards: uint32
|
||||||
|
friendCount: uint8
|
||||||
|
friendCards: set[0..255]
|
||||||
|
locationsKnown: set[0..127]
|
||||||
|
locationsUnlocked: set[0..127]
|
||||||
|
pickupsObtained: set[0..127]
|
||||||
|
pickupsUsed: set[0..127]
|
||||||
|
pickupCount: uint8
|
||||||
|
|
||||||
|
block: # bug #20914
|
||||||
|
block:
|
||||||
|
proc csizeof[T](a: T): int {.importc:"sizeof", nodecl.}
|
||||||
|
|
||||||
|
var s: GoodboySave
|
||||||
|
doAssert sizeof(s) == 108
|
||||||
|
doAssert csizeof(s) == static(sizeof(s))
|
||||||
|
|
||||||
|
block:
|
||||||
|
proc calignof[T](a: T): int {.importc:"alignof", header: "<stdalign.h>".}
|
||||||
|
|
||||||
|
var s: set[0..256]
|
||||||
|
doAssert alignof(s) == 1
|
||||||
|
doAssert calignof(s) == static(alignof(s))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue