mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-11 22:08:54 +00:00
* fixes #22419; async/closure environment does not align local variables * Apply suggestions from code review * Update tests/align/talign.nim Co-authored-by: Jacek Sieka <arnetheduck@gmail.com> * apply code review * update tests --------- Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
This commit is contained in:
@@ -237,6 +237,9 @@ proc addField*(obj: PType; s: PSym; cache: IdentCache; idgen: IdGenerator): PSym
|
||||
field.itemId = ItemId(module: s.itemId.module, item: -s.itemId.item)
|
||||
let t = skipIntLit(s.typ, idgen)
|
||||
field.typ = t
|
||||
if s.kind in {skLet, skVar, skField, skForVar}:
|
||||
#field.bitsize = s.bitsize
|
||||
field.alignment = s.alignment
|
||||
assert t.kind != tyTyped
|
||||
propagateToOwner(obj, t)
|
||||
field.position = obj.n.len
|
||||
|
||||
@@ -51,3 +51,19 @@ type Bug[T] = object
|
||||
|
||||
var bug: Bug[int]
|
||||
doAssert sizeof(bug) == 128, "Oops my size is " & $sizeof(bug) # 16
|
||||
|
||||
|
||||
block: # bug #22419
|
||||
type
|
||||
ValidatorPubKey = object
|
||||
blob: array[96, byte]
|
||||
|
||||
proc f(): auto =
|
||||
return iterator() =
|
||||
var pad: int8 = 0
|
||||
var y {.align: 16.}: ValidatorPubKey
|
||||
let value = cast[uint64](addr y)
|
||||
doAssert value mod 16 == 0
|
||||
|
||||
f()()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user