[Issue 259] Comparing signed to unsigned does not generate an error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 14 11:57:25 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=259
Éric Estièvenart <eric.estievenart at free.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |eric.estievenart at free.fr
--- Comment #19 from Éric Estièvenart <eric.estievenart at free.fr> 2011-01-14 11:55:24 PST ---
Indeed this is rather critical; I hit it in a simple precondition like:
void insert( Object o, int ndx = -1 ) // -1 means last
in { assert( ndx >= -1 && ndx <= somearray.length ); }
forcing to add a cast everywhere would be very painful...
The following code should compile without error and pass:
void main()
{
uint ulen = 0;
int ndx = -1;
assert( -1 <= ulen );
assert( ndx <= ulen );
}
If it generates warnings is another issue...
// This one should compile too
void func2()
{
uint u;
// should not compile (or at least warn): always yields to true
static assert( !is( typeof( u >= 0 ) ) );
static assert( !is( typeof( u >= -1 ) ) );
}
--
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