digitalmars.D.bugs - [Issue 22828] New: Compiler allow offset a pointer with types of
- d-bugmail puremagic.com (28/28) Feb 27 2022 https://issues.dlang.org/show_bug.cgi?id=22828
https://issues.dlang.org/show_bug.cgi?id=22828 Issue ID: 22828 Summary: Compiler allow offset a pointer with types of size greater than sizeof(T*) Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: critical Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: contact lsferreira.net The compiler allows offset a pointer on -m32 with ulong type. This should be illegal and doing so is dangerous, as overflow may happen. This pointer arithmetic should also conform with IndexExpr behaviour described in the language specification. ```d int main() { int i; ulong len; *(&i + len) = 0; // ok (&i)[len] = 0; // error return 0; } ``` --
Feb 27 2022