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: [email protected]
Reporter: [email protected]
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;
}
```
--