[Issue 17765] void initialisation of out parameters
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Aug 21 17:38:42 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17765
--- Comment #2 from Nicholas Wilson <iamthewilsonator at hotmail.com> ---
Yeah the compiler was not able to determine that all values were assigned
despite there being no conditional logic for the initialisation:
foreach(i; 0 .. M-1)
{
corr[i][i] = 1.0;
for (auto j = i+1; j < M; j++)
{
corr[i][j] = 0.0;
for (auto k = 0; k < N; k++)
corr[i][j] += data[k][i] * data[k][j];
corr[j][i] = corr[i][j];
}
}
foreach(i; 0 .. M) corr[M-1][i] = 0.0;
corr[M-1][M-1] = 1.0;
>I was wondering if this could more of an implementation detail in the function itself.
>
> i.e.:
>
> void g(out float[M][M] corr)
> {
> corr = void; // disables the initial write
> }
That would also work and would probably be less effort in the compiler and less
confusing.
> This shouldn't be allowed in @safe code.
Definitely.
--
More information about the Digitalmars-d-bugs
mailing list