July 30, 2018 [Issue 19128] New: argument to alloca may be too large | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19128 Issue ID: 19128 Summary: argument to alloca may be too large Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: druntime Assignee: nobody@puremagic.com Reporter: belka@caraus.de In rt.arrayassign._d_arraysetassign alloca is called if the buffer should be allocated is larger than 16 bytes: void[16] buf = void; void[] tmp; if (element_size > buf.sizeof) { tmp = alloca(element_size)[0 .. element_size]; } else tmp = buf[]; It is dangerous since alloca unavailable to allocate causes undefined behaviour, so the alloca man page states: The alloca() function returns a pointer to the beginning of the allocated space. If the allocation causes stack overflow, program behavior is undefined. See related discussion: https://github.com/D-Programming-GDC/GDC/pull/699 -- |
Copyright © 1999-2021 by the D Language Foundation