diff options
-rw-r--r-- | compiler/sizealignoffsetimpl.nim | 2 | ||||
-rw-r--r-- | tests/misc/tsizeof.nim | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/compiler/sizealignoffsetimpl.nim b/compiler/sizealignoffsetimpl.nim index dcff992a1..573b27094 100644 --- a/compiler/sizealignoffsetimpl.nim +++ b/compiler/sizealignoffsetimpl.nim @@ -122,7 +122,7 @@ proc computeObjectOffsetsFoldFunction(conf: ConfigRef; n: PNode, initialOffset: let size = n.sym.typ.size let align = n.sym.typ.align result.align = align - if initialOffset == szUnknownSize: + if initialOffset == szUnknownSize or size == szUnknownSize: n.sym.offset = szUnknownSize result.offset = szUnknownSize else: diff --git a/tests/misc/tsizeof.nim b/tests/misc/tsizeof.nim index ecdd44fca..2830a545f 100644 --- a/tests/misc/tsizeof.nim +++ b/tests/misc/tsizeof.nim @@ -350,5 +350,19 @@ testinstance: main() +{.emit: """/*TYPESECTION*/ +typedef struct{ + float a; float b; +} Foo; +""".} + +type + Foo {.importc.} = object + + Bar = object + b: byte + foo: Foo + +assert sizeof(Bar) == 12 echo "OK" |