[Issue 21928] New: Wrong location for "array literal in @nogc function main may cause GC allocation" error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 18 15:45:48 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21928
Issue ID: 21928
Summary: Wrong location for "array literal in @nogc function
main may cause GC allocation" error
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: diagnostic
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dlang-bugzilla at thecybershadow.net
//////////////// test.d ////////////////
@nogc:
struct Shape
{
immutable size_t[] dims = [];
}
void main()
{
auto s = Shape(2 ~ Shape.init.dims);
}
////////////////////////////////////////
Output:
test.d(3): Error: array literal in @nogc function D main may cause a GC
allocation
Seems to be a particularly bad variant of issue 21871. It misleadingly places
the blame on the initializer as if it is causing a GC allocation. Instead, the
error should be placed at the ~ operator.
--
More information about the Digitalmars-d-bugs
mailing list