Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/ccgtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ proc isInvalidReturnType(conf: ConfigRef; rettype: PType): bool =
# such a poor programming language.
# We exclude records with refs too. This enhances efficiency and
# is necessary for proper code generation of assignments.
if rettype == nil or getSize(conf, rettype) > conf.target.floatSize*3:
if rettype == nil or (tfByCopy notin rettype.flags and getSize(conf, rettype) > conf.target.floatSize*3):
result = true
else:
case mapType(conf, rettype, skResult)
Expand Down
12 changes: 12 additions & 0 deletions tests/objects/m19342.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
struct Node
{
int data[25];
};


struct Node hello(int name) {
struct Node x = {999, 1, 2, 3, 4, 5, 6, 7, 8, 9,
0, 1, 2, 3, 4, 5, 6, 7 ,8, 9,
1, 2, 3, 4, 5};
return x;
}
18 changes: 18 additions & 0 deletions tests/objects/t19342.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
discard """
targets: "c cpp"
"""

{.compile: "m19342.c".}

# bug #19342
type
Node* {.bycopy.} = object
data: array[25, cint]

proc myproc(name: cint): Node {.importc: "hello", cdecl.}

proc parse =
let node = myproc(10)
doAssert node.data[0] == 999

parse()