digitalmars.D.bugs - [Issue 1257] New: Erroneous warning for ushort = (ushort | ushort)
- d-bugmail puremagic.com (30/30) Jun 04 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1257
- d-bugmail puremagic.com (10/10) Sep 26 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1257
- d-bugmail puremagic.com (8/11) Sep 26 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1257
- d-bugmail puremagic.com (9/9) Dec 08 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1257
- d-bugmail puremagic.com (8/8) Dec 08 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1257
http://d.puremagic.com/issues/show_bug.cgi?id=1257 Summary: Erroneous warning for ushort = (ushort | ushort) Product: D Version: 1.014 Platform: PC OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: clugdbug yahoo.com.au void main(){ ushort a = 1; ushort b = 2; ushort c = a|b; } dmd -w bug.d warning - bug.d(5): Error: implicit conversion of expression (cast(int)a | cast( int)b) of type int to ushort can cause loss of data ------- This is ridiculous. Logical operations on two operands of the same size should not be implicitly converted. The code above is _never_ a bug. This is particularly bad because int c = a|b; does _not_ generate a warning, even though it involves a change from unsigned to signed, _and_ a change of size, and is therefore likely to be a bug! --
Jun 04 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1257 paching gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |paching gmail.com ------- Comment #1 from paching gmail.com 2008-09-26 23:53 ------- I've been bitten by this too. Simple operations like assigning the sum of two shorts to another short give warnings; I've had to shut them off as a workaround. --
Sep 26 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1257 ------- Comment #2 from andrei metalanguage.com 2008-09-27 00:18 ------- (In reply to comment #1)I've been bitten by this too. Simple operations like assigning the sum of two shorts to another short give warnings; I've had to shut them off as a workaround.I think the sum of any integrals smaller than int/uint should result in int/uint, so that warning is legit in that case. The reason is a mix of being principled (operations should avoid overflow) and being practical (int won't spill into long). Bitwise operations should indeed preserve size. --
Sep 26 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1257 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #3 from bugzilla digitalmars.com 2008-12-08 03:39 ------- It doesn't give those warnings anymore. --
Dec 08 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1257 smjg iname.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com ------- Comment #4 from smjg iname.com 2008-12-08 05:51 ------- See also issue 1977. --
Dec 08 2008