Comment #0 by verylonglogin.reg — 2014-06-13T09:08:49Z
This code should compile without warnings:
---
int f(immutable(int[])[int] a) pure nothrow
{
a[0] = [];
return 0;
}
void main()
{
immutable(int[])[int] aa;
aa.f();
}
---
main.d(10): Warning: calling main.f without side effects discards return value of type int, prepend a cast(void) if intentional
---
This is a major issue as it creates release-only bugs also depending on `-inline` switch as optimizer can not call such functions if it isn't already inlined:
---
import std.stdio;
void f(immutable(string)[int] a) pure nothrow
{
// This `try` is needed to prevent inlining if compiled
// with `-inline`:
try debug writeln("f called."); catch { }
a[1] = "a";
}
void main()
{
immutable(string)[int] aa = [0 : ""];
aa.f();
writeln(aa);
}
---
Writes `[0:""]` if optimized.
Comment #1 by verylonglogin.reg — 2014-06-13T09:23:39Z
Correction:
The issue is triggered in case of AA key being a non-mutable array or pointer, e.g.: `const(int[])[int]` or `const(int*)[int]`.