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;
}
```
Comment #1 by dlang-bot — 2022-02-27T21:49:34Z
@ljmf00 created dlang/dmd pull request #13732 "Fix issue 22828: dcast: use an implicit cast instead of explicit" fixing this issue:
- Fix issue 22828: dcast: use an implicit cast instead of explicit
Signed-off-by: Luís Ferreira <[email protected]>
https://github.com/dlang/dmd/pull/13732
Comment #2 by razvan.nitu1305 — 2022-02-28T10:57:23Z
What is the basis of your assumption that this should be illegal? You are doing pointer arithmetic in @System code, it is not the job of the compiler to prevent you from doing something like this. I don't think the bug report is valid.
Comment #3 by robert.schadek — 2024-12-13T19:21:14Z