[Issue 21617] dmd -boundscheck=off segfault when accessing an array's index with a function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 9 10:51:37 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21617

ag0aep6g <ag0aep6g at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com

--- Comment #1 from ag0aep6g <ag0aep6g at gmail.com> ---
Reduced:

----
int[1] a13 = [13];
int[1] a42 = [42];
int[] slice;
size_t foo()
{
    slice = a42[];
    return 0;
}
int main()
{
    slice = a13[];
    return slice[foo()];
}
----

With `-boundscheck=off`, the program returns 13. With bounds checking, it
returns 42.

Looks like `-boundscheck` affects the order of evaluation.

--


More information about the Digitalmars-d-bugs mailing list