Bug 17721 – Wrong expression type using vector extensions with shift operands
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-08-04T23:59:44Z
Last change time
2017-08-16T13:24:21Z
Assigned to
Iain Buclaw
Creator
Iain Buclaw
Comments
Comment #0 by ibuclaw — 2017-08-04T23:59:44Z
The operands encapsulated by the following classes have a result type that is implicitly bool.
CmpExp
EqualExp
IdentityExp
The operands encapsulated by the following classes have a result type that is implicitly int.
ShlExp
ShrExp
UshrExp
When handling vectors, the resultant type of the expression should also be a vector. i.e:
---
float4 f1 = [1, 9, 8, 9];
float4 f2 = [2, 8, 0, 5];
float4 fr = f1 > f2;
assert((f1 > f2).array == [0, -1, -1, -1]);
int4 i1 = [1, 2, 3, 4];
int4 i2 = [2, 4, 8, 16];
int4 ir = i1 << i2;
assert(ir.array == [4, 32, 768, 262144]);
---
This is not a concern for dmd, who rejects these operands.