[Issue 23514] New: Incorrect compilation when adding a 64-bit constant to a link-time address
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Nov 27 08:25:52 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23514
Issue ID: 23514
Summary: Incorrect compilation when adding a 64-bit constant to
a link-time address
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: zyedidia at stanford.edu
This code adds a large constant to the address of main, but the offset is
truncated to 32 bits by the compiler, resulting in an incorrect result.
```
enum offset = 0xFFFF_FFFF_0000_0000UL;
extern (C) void main() {
assert((cast(ulong)&main) != (cast(ulong)&main + offset));
}
```
The assertion should pass (&main should not equal &main + 64-bit constant), but
it fails.
The assertion fails with DMD master and LDC 1.30.0 (didn't test on master), but
passes with GDC 10.3.0.
I will open a PR with the small fix for this shortly.
--
More information about the Digitalmars-d-bugs
mailing list