[Issue 1977] Relax warnings (D1)/errors (D2) for implicit narrowing conversions caused by promotions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 8 08:51:34 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=1977


Stewart Gordon <smjg at iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|2.012                       |unspecified
            Summary|Relax warnings for implicit |Relax warnings (D1)/errors
                   |narrowing conversions       |(D2) for implicit narrowing
                   |caused by promotions        |conversions caused by
                   |                            |promotions
         OS/Version|Linux                       |All




--- Comment #21 from Stewart Gordon <smjg at iname.com>  2009-08-08 08:51:28 PDT ---
(In reply to comment #20)
> Here's a related issue:
> 
> long a;
> ...
> int b = a % 1000;
> 
> The sample above gives an error that it can't implicitly convert to int, even
> though this us exactly the kind of thing implicit narrowing conversions should
> handle.

That's different, since it isn't due to promotions beyond the lowest common
denominator of the operand types.

The best way to deal with this is to spec that the type of a % expression (and
similarly &) on integers is the smaller of the operands' types.  There's no
loss of significant digits this way, at least if they're both signed or both
unsigned.  But if one's signed and the other's unsigned, _then_ what should
happen?

If you're worried about breaking existing D1 code, this can still be achieved
by doing this only to the base type and not the promoted type (using the
terminology I introduced at
http://www.digitalmars.com/d/archives/24706.html#N24797
)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list