A variation of issue 11977?
Paul Backus
snarwin at gmail.com
Thu Jan 21 14:09:58 UTC 2021
On Thursday, 21 January 2021 at 13:55:48 UTC, kdevel wrote:
> ~~~gotoskip.d
> int main ()
> {
> string[string] aa;
> goto A; // line 4
> aa["X"] = "Y"; // line 5
> A:
> return 0;
> }
> ~~~
>
> $ dmd gotoskip.d
> gotoskip.d(4): Error: goto skips declaration of variable
> gotoskip.main.__aaval2 at gotoskip.d(5)
>
> What's wrong here? Only found Issue 11977 [1] in which a
> declaration and
> initialization is jumped over. However, the statement in line 5
> is neither
> a declaration nor an initialization.
>
> [1] https://issues.dlang.org/show_bug.cgi?id=11977
__aaval2 is a compiler-generated temporary variable. If you
comment out the `goto A;` (so that the code compiles) and use the
compiler flag -vcg-ast, you can see its declaration:
int main()
{
string[string] aa = null;
// goto A;
(string __aaval2 = "Y";) , aa["X"] = __aaval2;
A:
return 0;
}
More information about the Digitalmars-d-learn
mailing list