[Issue 23146] New: bounds checking is still done in @system functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun May 29 04:23:51 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23146
Issue ID: 23146
Summary: bounds checking is still done in @system functions
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: bugzilla at digitalmars.com
Given:
@system int test(int[] a) { return a[3]; }
and compiling it with -vasm:
_D4testQfFAiZi:
0000: 55 push RBP
0001: 48 8B EC mov RBP,RSP
0004: 48 83 EC 20 sub RSP,020h
0008: 48 89 5D E8 mov -018h[RBP],RBX
000c: 48 89 7D F0 mov -010h[RBP],RDI
0010: 48 89 75 F8 mov -8[RBP],RSI
0014: B8 03 00 00 00 mov EAX,3
0019: 48 3B F8 cmp RDI,RAX
001c: 77 15 ja L33
001e: 48 89 F9 mov RCX,RDI
0021: 48 89 C2 mov RDX,RAX
0024: BE 07 00 00 00 mov ESI,7
0029: BF 00 00 00 00 mov EDI,0
002e: E8 00 00 00 00 call L0
0033: 48 8B 55 F8 mov RDX,-8[RBP]
0037: 48 8B 5D F0 mov RBX,-010h[RBP]
003b: 8B 42 0C mov EAX,0Ch[RDX]
003e: 48 8B 5D E8 mov RBX,-018h[RBP]
0042: C9 leave
0043: C3 ret
as you can see, the bounds check is there. Now let's compile it with
-boundscheck=off:
0000: 55 push RBP
0001: 48 8B EC mov RBP,RSP
0004: 48 83 EC 10 sub RSP,010h
0008: 48 89 7D F0 mov -010h[RBP],RDI
000c: 48 89 75 F8 mov -8[RBP],RSI
0010: 48 8B 55 F8 mov RDX,-8[RBP]
0014: 48 8B 45 F0 mov RAX,-010h[RBP]
0018: 8B 42 0C mov EAX,0Ch[RDX]
001b: C9 leave
001c: C3 ret
and no bounds check.
This bug was introduced by https://github.com/dlang/dmd/pull/14170
--
More information about the Digitalmars-d-bugs
mailing list