Thread overview
[Issue 21617] dmd -boundscheck=off segfault when accessing an array's index with a function
Sep 09, 2021
ag0aep6g
Dec 17, 2022
Iain Buclaw
May 20, 2021
https://issues.dlang.org/show_bug.cgi?id=21617

moonlightsentinel@disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |backend
                 CC|                            |moonlightsentinel@disroot.o
                   |                            |rg

--
September 09, 2021
https://issues.dlang.org/show_bug.cgi?id=21617

ag0aep6g <ag0aep6g@gmail.com> changed:

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

--- Comment #1 from ag0aep6g <ag0aep6g@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.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=21617

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

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

--- Comment #2 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19866

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--