struct Foo
{
immutable(int)[] list;
}
unittest
{
enum foo = Foo([1, 2, 3]);
foo.list ~= 4;
}
ICE with DMD64 D Compiler v2.065-devel-2318831:
Internal error: backend/cgcs.c 351
May be related to https://d.puremagic.com/issues/show_bug.cgi?id=11596
Comment #1 by hsteoh — 2014-01-15T08:15:53Z
Can't reproduce problem on latest git HEAD (786ea8228f836b1d80b36b991c534256ea6c9592). Tested on Linux/64bit. Has this bug been fixed, or is it a platform-specific issue?
Comment #2 by dransic — 2014-01-15T09:00:30Z
(In reply to comment #1)
> Can't reproduce problem on latest git HEAD
> (786ea8228f836b1d80b36b991c534256ea6c9592). Tested on Linux/64bit. Has this bug
> been fixed, or is it a platform-specific issue?
Yes, still there for me for this same commit.
dmd -main -unittest -run test.d
Internal error: backend/cgcs.c 351
dmd -main -unittest -O -run test.d
Internal error: backend/cod2.c 4964
on Mac OSX 10.9,
DMD64 D Compiler v2.065-devel-786ea82
Reproduced error in git HEAD, only happens when compiling with -unittest.
Comment #5 by b2.temp — 2019-05-31T10:21:33Z
reduced, no need for -unittest, should be a fail compilation:
---
struct Foo
{
int[] list;
}
void main()
{
enum foo = Foo([]);
foo.list ~= 4;
}
---
because `foo.list` is not modifiable (or not a Lvalue).
The error must be detected in the front-end.
Comment #6 by b2.temp — 2019-11-22T21:06:50Z
2.082.1 to 2.084.1: Status -4 and no output
2.085.1: Success and no output
2.086.1: Status -4 and no output
Since 2.087.1: Failure with output: onlineapp.d(9): Error: cannot modify constant expression `Foo([]).list`