Skip to content

RVO not applied to object with large array #14470

@arnetheduck

Description

@arnetheduck
type X = object
  v: array[1024*1024*8, int]

proc f(): X =
  result.v[0] = 1

var x = (ref X)()
x[] = f()
echo x.v[0]

note how huge object is placed on stack, crashing the application on linux (which has an 8mb default stack size)

N_LIB_PRIVATE N_NIMCALL(tyObject_X__KqwtR1mZdQ5eNccTtsN3pA, f__KQQBzps5MRoTwkbIifdBMQ)(void) {
        tyObject_X__KqwtR1mZdQ5eNccTtsN3pA result;
...
        return result;
[arnetheduck@tempus tmp]$ nim --version
Nim Compiler Version 1.2.0 [Linux: amd64]
Compiled at 2020-04-03
Copyright (c) 2006-2020 by Andreas Rumpf

active boot switches: -d:release

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions