[Issue 20353] New: -checkaction=context does not work well with const numbers
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 4 21:24:07 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20353
Issue ID: 20353
Summary: -checkaction=context does not work well with const
numbers
Product: D
Version: D2
Hardware: x86_64
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dkorpel at live.nl
When compiling with -checkaction=context:
```D
void main() {
const x = -1L;
const y = -2L;
assert(x == y);
}
```
expected: -1 != -2
actual: assert(x == y) failed
Also applies to floating points. I don't know why it fails to give context
here. Making either x or y mutable makes it work.
Also:
```D
void main() {
const long[1] x = [uint.max];
const long[1] y = [-1];
assert(x == y);
}
```
expected: [4294967296] != [-1]
actual: [-1] != [-1]
This is because in core.internal.dassert: getPrintfFormat there is a check:
static if (is(T == long))
This doesn't Unqual T so it doesn't hold when T == const(long), so it chooses
the wrong format.
--
More information about the Digitalmars-d-bugs
mailing list