Bug 15261 – [dmd-internal] Trivial problem in BinExp.checkOpAssignTypes

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-10-30T01:13:00Z
Last change time
2016-01-03T14:02:15Z
Keywords
pull
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2015-10-30T01:13:55Z
In BinExp.checkOpAssignTypes: if (op == TOKmulass || op == TOKdivass || op == TOKmodass || TOKaddass || // TOK enum is used as a boolean value! op == TOKminass || op == TOKpowass) { if ((type.isintegral() && t2.isfloating())) { warning("%s %s %s is performing truncating conversion", type.toChars(), Token.toChars(op), t2.toChars()); } } But this is not a real problem, because: 1. checkOpAssignTypes is called only from BinAssignExp.semantic 2. BinAssignExp.semantic is used by these concrete classes derived from BinAssignExp: (Add|Min|Mul|Div|Mod|Pow)AssignExp (And|Or|Xor)AssignExp (Shl|Shr|Ushr)AssignExp 3. However, BinAssignExp.e2.type can have floating point type only in: (Add|Min|Mul|Div|Mod|Pow)AssignExp Other cases are rejected before the call of checkOpAssignTypes in BinAssignExp.semantic. Test case (compile with -o- -w): void main() { int x; double y; x += y; // AddAssignExp -> warning, expected x -= y; // MinAssignExp -> warning, expected x *= y; // MulAssignExp -> warning, expected x /= y; // DivAssignExp -> warning, expected x %= y; // ModAssignExp -> warning, expected x ^^= y; // PowAssignExp -> warning, expected x &= y; // AndAssignExp -> error, does not reach to checkOpAssignTypes call x |= y; // OrAssignExp -> error, ditto x ^= y; // XorAssignExp -> error, ditto x <<= y; // ShlAssignExp -> error, ditto x >>= y; // ShrAssignExp -> error, ditto x >>>= y; // UshrAssignExp -> error, ditto }
Comment #1 by k.hara.pg — 2015-10-30T01:24:31Z
Comment #2 by github-bugzilla — 2015-10-30T10:46:00Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/759d27b90492864aae4c55d4071c2d666928a0fe fix Issue 15261 - [dmd-internal] Trivial problem in BinExp.checkOpAssignTypes https://github.com/D-Programming-Language/dmd/commit/be3d6f907f33fad3624b5e5057314454d2cd2171 Merge pull request #5240 from 9rnsr/fix_internal_bugs Issue 15260, 15261, 15262 - Fix dmd-internal bugs
Comment #3 by github-bugzilla — 2016-01-03T14:02:15Z
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/759d27b90492864aae4c55d4071c2d666928a0fe fix Issue 15261 - [dmd-internal] Trivial problem in BinExp.checkOpAssignTypes https://github.com/D-Programming-Language/dmd/commit/be3d6f907f33fad3624b5e5057314454d2cd2171 Merge pull request #5240 from 9rnsr/fix_internal_bugs