October 13, 2012 [Issue 1977] Relax warnings (D1)/errors (D2) for implicit narrowing conversions caused by promotions | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1977 --- Comment #26 from Ryuichi OHORI <r.97all@gmail.com> 2012-10-13 04:28:56 PDT --- > Your example is perfectly valid. I don't see. In the example above( http://dpaste.dzfl.pl/8b9f5471 ), the value in y is 16777216, which is greater than ushort.max. > It knows the value of both x and y, so it knows that x |= y; will work just fine, because all of the values will fit in the correct types. If the value in y was too large to fit in a ushort, _then_ it should give you an error, but since it fits in a ushort just fine (and is positive, so there's no issues with two's complement or whatnot), the compiler knows that it's fine and allows it without complaint. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 13, 2012 [Issue 1977] Relax warnings (D1)/errors (D2) for implicit narrowing conversions caused by promotions | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1977 --- Comment #27 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-10-13 09:16:49 PDT --- > I don't see. In the example above( http://dpaste.dzfl.pl/8b9f5471 ), the value in y is 16777216, which is greater than ushort.max. I thought that I tested that it wasn't, but I guess that I screwed that up, since upon testing it again, it looks like it indeed is greater than ushort.max, But what's probably happening then is that x gets promoted to (u)int for |= per the integral promotion rules and then is fine being reassigned to x because the result is only 4, which fits in a ushort just fine. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 13, 2012 [Issue 1977] Relax warnings (D1)/errors (D2) for implicit narrowing conversions caused by promotions | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1977 --- Comment #28 from Ryuichi OHORI <r.97all@gmail.com> 2012-10-13 09:23:44 PDT --- (In reply to comment #27) > reassigned to x because the result is only 4, which fits in a ushort just fine. The result is 16777220 if both operands are int. I think this is an implicit narrowing conversion. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 13, 2012 [Issue 1977] Relax warnings (D1)/errors (D2) for implicit narrowing conversions caused by promotions | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1977 --- Comment #29 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-10-13 12:35:13 PDT --- > The result is 16777220 if both operands are int. I think this is an implicit narrowing conversion. Ah. Then yes, it sounds like it's doing the wrong thing. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation