[Issue 14639] Assigning init value to struct uses stack, causing segfault
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed May 10 08:50:27 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=14639
--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
The code:
biggy = Biggy.init;
gets rewritten to be:
biggy = Biggy([0LU, ...]);
which is a construction. The postblit caused an opAssign() to be created, and
the expression is further rewritten to:
biggy.opAssign(Biggy([0LU, ...]));
which blows up the parameter stack because Biggy([0LU, ...]) is too big for it.
The operation is not disabled because it gets constructed in place - a copy is
not being made.
A possible compiler fix is to figure out that the generated opAssign is trivial
and can be replaced with a bit copy. The code in opover.d:
if (sd && !sd.hasIdentityAssign)
{
/* This is bitwise struct assignment. */
return;
}
can be modified to test for triviality of identity assign, and use a bitwise
copy.
--
More information about the Digitalmars-d-bugs
mailing list