D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3280 - comparing array length is wonky
Summary: comparing array length is wonky
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-01 16:39 UTC by Ellery Newcomer
Modified: 2015-06-09 01:28 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ellery Newcomer 2009-09-01 16:39:31 UTC
void main(){
    string s;
    int a = s.length;
    assert(a == 0);
    assert(s.length == 0);
    assert(a == 0);
    assert(a > -1);
    assert(s.length > -1); //fails
}
Comment 1 Jarrett Billingsley 2009-09-01 17:09:24 UTC
Sorry, invalid. typeof(s.length) is unsigned, typeof(-1) is signed. The compiler should throw an error on the last assert, but doesn't. Instead, it casts -1 to size_t, resulting in something like "assert(s.length > 0xFFFFFFFF);" See bug 259.
Comment 2 Jarrett Billingsley 2009-09-01 17:09:39 UTC
Oops