digitalmars.D.learn - A variation of issue 11977?
- kdevel (19/19) Jan 21 2021 ~~~gotoskip.d
- Paul Backus (12/31) Jan 21 2021 __aaval2 is a compiler-generated temporary variable. If you
- kdevel (4/7) Jan 21 2021 Creating a scope
- z (5/7) Jan 21 2021 Another way to work around the issue is to use «asm {jmp label;}»
- kdevel (3/3) Jan 21 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
Jan 21 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; }
Jan 21 2021
On Thursday, 21 January 2021 at 13:55:48 UTC, kdevel wrote:goto A; // line 4 aa["X"] = "Y"; // line 5 A:Creating a scope { aa["X"] = "Y"; } // line 5 works around the issue.
Jan 21 2021
On Thursday, 21 January 2021 at 14:11:15 UTC, kdevel wrote:Creating a scope works around the issue.Another way to work around the issue is to use «asm {jmp label;}» (replace jmp by whatever equivalent is there on the target architecture.) Yes it's ugly, but it bypasses the arbitrary limitation perfectly.
Jan 21 2021
On Thursday, 21 January 2021 at 13:55:48 UTC, kdevel wrote: [...] created https://issues.dlang.org/show_bug.cgi?id=21571
Jan 21 2021