parent
67a6effb7b
commit
d563efb719
2 changed files with 31 additions and 1 deletions
|
|
@ -169,7 +169,7 @@ proc computeObjectOffsetsFoldFunction(conf: ConfigRef; n: PNode,
|
||||||
align = n.sym.typ.align.int
|
align = n.sym.typ.align.int
|
||||||
|
|
||||||
result.align = align
|
result.align = align
|
||||||
if initialOffset == szUnknownSize or size == szUnknownSize:
|
if initialOffset == szUnknownSize or size == szUnknownSize or align == szUnknownSize:
|
||||||
n.sym.offset = szUnknownSize
|
n.sym.offset = szUnknownSize
|
||||||
result.offset = szUnknownSize
|
result.offset = szUnknownSize
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,33 @@ proc toByteArrayBE*[T: SomeInteger](num: T): ByteArrayBE[sizeof(T)]=
|
||||||
|
|
||||||
let a = 12345.toByteArrayBE
|
let a = 12345.toByteArrayBE
|
||||||
echo a[^2 .. ^1] # to make it work on both 32-bit and 64-bit
|
echo a[^2 .. ^1] # to make it work on both 32-bit and 64-bit
|
||||||
|
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------
|
||||||
|
|
||||||
|
# bug #11792
|
||||||
|
type
|
||||||
|
m256d {.importc: "__m256d", header: "immintrin.h".} = object
|
||||||
|
|
||||||
|
MyKind = enum
|
||||||
|
k1, k2, k3
|
||||||
|
|
||||||
|
MyTypeObj = object
|
||||||
|
kind: MyKind
|
||||||
|
x: int
|
||||||
|
amount: UncheckedArray[m256d]
|
||||||
|
|
||||||
|
|
||||||
|
# The sizeof(MyTypeObj) is not equal to (sizeof(int) + sizeof(MyKind)) due to
|
||||||
|
# alignment requirement of m256d, make sure Nim understands that
|
||||||
|
doAssert(sizeof(MyTypeObj) > sizeof(int) + sizeof(MyKind))
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------
|
||||||
|
|
||||||
|
type
|
||||||
|
Payload = object
|
||||||
|
something: int
|
||||||
|
vals: UncheckedArray[int]
|
||||||
|
|
||||||
|
static:
|
||||||
|
doAssert(compiles(offsetOf(Payload, vals)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue