[Issue 20383] New: [REG 2.084.z] illegal conversion from int[] to ubyte[] are accepted
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 11 00:58:46 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20383
Issue ID: 20383
Summary: [REG 2.084.z] illegal conversion from int[] to ubyte[]
are accepted
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ice, wrong-code
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: b2.temp at gmx.com
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)`
--
More information about the Digitalmars-d-bugs
mailing list