Sizeof alignof fixes (#9568)

fixes #9545
This commit is contained in:
Arne Döring
2018-10-30 16:41:06 +01:00
committed by Andreas Rumpf
parent 432a4d1787
commit 1ec5c6fdf5
2 changed files with 15 additions and 1 deletions

View File

@@ -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:

View File

@@ -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"