fixes #9403
This commit is contained in:
parent
e42c304e4a
commit
0ecaaa85e9
2 changed files with 21 additions and 2 deletions
|
|
@ -1912,7 +1912,7 @@ proc genOrd(p: BProc, e: PNode, d: var TLoc) =
|
||||||
|
|
||||||
proc genSomeCast(p: BProc, e: PNode, d: var TLoc) =
|
proc genSomeCast(p: BProc, e: PNode, d: var TLoc) =
|
||||||
const
|
const
|
||||||
ValueTypes = {tyTuple, tyObject, tyArray, tyOpenArray, tyVarargs}
|
ValueTypes = {tyTuple, tyObject, tyArray, tyOpenArray, tyVarargs, tyUncheckedArray}
|
||||||
# we use whatever C gives us. Except if we have a value-type, we need to go
|
# we use whatever C gives us. Except if we have a value-type, we need to go
|
||||||
# through its address:
|
# through its address:
|
||||||
var a: TLoc
|
var a: TLoc
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''12'''
|
output: '''12
|
||||||
|
4'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
{.emit: """
|
{.emit: """
|
||||||
|
|
@ -26,3 +27,21 @@ p(@[1])
|
||||||
q(@[1])
|
q(@[1])
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
# bug #9403
|
||||||
|
|
||||||
|
type
|
||||||
|
MyObj = ref object
|
||||||
|
len: int
|
||||||
|
val: UncheckedArray[uint64]
|
||||||
|
|
||||||
|
proc spot(x: MyObj): int64 =
|
||||||
|
result = cast[UncheckedArray[int64]](x.val)[0]
|
||||||
|
|
||||||
|
proc newMyObj(len: int): MyObj =
|
||||||
|
unsafeNew(result, sizeof(result[]) + len * sizeof(uint64))
|
||||||
|
result.len = len
|
||||||
|
result.val[0] = 4u64
|
||||||
|
result.val[1] = 8u64
|
||||||
|
|
||||||
|
echo spot(newMyObj(2))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue