Bug 20383 – [REG 2.084.z] illegal conversion from int[] to ubyte[] is accepted
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-11-11T00:58:46Z
Last change time
2019-12-18T21:34:54Z
Keywords
ice, pull, wrong-code
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2019-11-11T00:58:46Z
This code compiles since 2.084.(1/0?) but it is illegal:
---
ubyte[1] ice(ubyte[1] data)
{
ubyte[1] result = data[] & [42];
return result;
}
void main()
{
assert (ice([1]) == [0]);
}
---
But fails at runtime with a range violation.
Previously it was rejected with the message:
---
Error: cannot implicitly convert expression `data[] & [42]` of type `int[]` to `ubyte[]`
---
Which should still be the case, unless 42 is cast to ubyte or constructed as ubyte(42).
The backend has a protection to detect the illegal element but it's not written correctly. It uses the style `assert(!condition)` instead of `if (condition) assert(0);` and because of that an ICE does not happen when DMD is compiled with -release. See `dmd.e2ir.toElemBin(BinExp be, int op)`
Comment #1 by bugzilla — 2019-12-07T07:01:30Z
It does work with DMD 2.074. Anyone want to do a bisect to see which PR broke it?
Comment #2 by dlang-bot — 2019-12-07T08:24:32Z
@WalterBright created dlang/dmd pull request #10642 "fix Issue 20383 - [REG 2.084.z] illegal conversion from int[] to ubyt…" fixing this issue:
- fix Issue 20383 - [REG 2.084.z] illegal conversion from int[] to ubyte[] is accepted
https://github.com/dlang/dmd/pull/10642
Comment #3 by dlang-bot — 2019-12-18T21:34:54Z
dlang/dmd pull request #10642 "fix Issue 20383 - [REG 2.084.z] illegal conversion from int[] to ubyt…" was merged into stable:
- ebeb86e36e2bdf6fbee065bed313cfc3cbdedb0d by Walter Bright:
fix Issue 20383 - [REG 2.084.z] illegal conversion from int[] to ubyte[] is accepted
https://github.com/dlang/dmd/pull/10642