[Issue 7834] Assign x%int to int without cast

2012-04-24 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7834



--- Comment #7 from bearophile_h...@eml.cc 2012-04-24 19:39:48 PDT ---
(In reply to comment #6)

> These two bits of code aren't analogous.
> If y was -1, when cast to ulong it becomes 0x___
> Therefore, x % y could be 0.. ulong.max; there's no way that can fit into an
> int.
> The compiler is correct.

You are of course right, thank you Don and sorry SomeDude.


> OTOH if you change int -> uint, it works.


Right, this compiles:

void main() {
ulong x;
uint y = 1;
int z = x % y;
}

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


[Issue 7834] Assign x%int to int without cast

2012-04-23 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7834


Don  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||clugd...@yahoo.com.au
 Resolution||INVALID


--- Comment #6 from Don  2012-04-23 03:23:44 PDT ---
(In reply to comment #0)
> In DMD 2.059beta this code compiles with no warnings or errors:
> void main(string[] args) {
> uint x;
> ubyte y = cast(ubyte)args.length;
> ubyte z = x % y;
> }

> So I'd like code similar to this too to compile with no need of a cast:
> void main() {
> ulong x;
> int y;
> int z = x % y;
> }

These two bits of code aren't analogous.
If y was -1, when cast to ulong it becomes 0x___
Therefore, x % y could be 0.. ulong.max; there's no way that can fit into an
int.
The compiler is correct.

OTOH if you change int -> uint, it works.

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


[Issue 7834] Assign x%int to int without cast

2012-04-22 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7834



--- Comment #5 from bearophile_h...@eml.cc 2012-04-22 11:57:20 PDT ---
(In reply to comment #4)
> That doesn't make any sense. You can't promote a 64 bit unsigned type into a 
> 32
> bit signed type.

Give me some time to think some more about it, I have a backlog of bugs to take
a look at (thanks to your recent efforts).

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


[Issue 7834] Assign x%int to int without cast

2012-04-22 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7834



--- Comment #4 from SomeDude  2012-04-22 10:43:27 
PDT ---
That doesn't make any sense. You can't promote a 64 bit unsigned type into a 32
bit signed type.

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


[Issue 7834] Assign x%int to int without cast

2012-04-22 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7834



--- Comment #3 from bearophile_h...@eml.cc 2012-04-22 03:35:15 PDT ---
(In reply to comment #2)
> (In reply to comment #1)
> > Now I think this is supposed to work, so it's not an enhancement request.
> 
> I don't see where in the spec ulong can be promoted to int.
> http://dlang.org/type.html

Thank you, then I think the spec too need to be fixed.

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


[Issue 7834] Assign x%int to int without cast

2012-04-21 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7834


SomeDude  changed:

   What|Removed |Added

 CC||lovelyd...@mailmetrash.com


--- Comment #2 from SomeDude  2012-04-21 10:25:02 
PDT ---
(In reply to comment #1)
> Now I think this is supposed to work, so it's not an enhancement request.

I don't see where in the spec ulong can be promoted to int.
http://dlang.org/type.html

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


[Issue 7834] Assign x%int to int without cast

2012-04-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7834


bearophile_h...@eml.cc changed:

   What|Removed |Added

Summary|Assign x%int to int without |Assign x%int to int without
   |cast?   |cast
   Severity|enhancement |normal


--- Comment #1 from bearophile_h...@eml.cc 2012-04-11 16:02:44 PDT ---
Now I think this is supposed to work, so it's not an enhancement request.

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