[Issue 22372] Loop index incorrectly optimised out for -release -O
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 12 05:17:01 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22372
Walter Bright <bugzilla at digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla at digitalmars.com
--- Comment #10 from Walter Bright <bugzilla at digitalmars.com> ---
A simplified version:
import core.stdc.stdio;
struct S { int a1, a2, a3; }
void throws2ndCall(ref S x)
{
__gshared bool b;
if (b)
throw new Exception("n == 1");
b = true;
}
void main()
{
S[] arr = [S(), S()];
size_t i;
try
{
for (i = 0; i < 2; i++)
throws2ndCall(arr[i]);
}
catch (Exception o)
{
printf("Exception: i = %lu\n", i); // prints 0
assert(i == 1); // this fails
}
}
--
More information about the Digitalmars-d-bugs
mailing list