[Issue 4342] New: branches that are known as not taken at compile time should not be checked
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jun 18 02:46:47 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4342
Summary: branches that are known as not taken at compile time
should not be checked
Product: D
Version: D1
Platform: Other
OS/Version: Mac OS X
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: fawzi at gmx.ch
--- Comment #0 from Fawzi Mohamed <fawzi at gmx.ch> 2010-06-18 02:46:43 PDT ---
I see the following code as valid, and thus the present bug as "rejects-valid"
{{{
module bug;
extern(C) int printf(char*,...);
void f(S...)(S args){
if (args[0].length>1 && args[0][1]>='0' && args[0][1]<='9'){
printf("bla,%d\n",args[0][1]-'0');
}
}
void main(){
f("x");
}
}}}
while the check in the if is correctly ignored (as it is unreachable because
the length of args[0] is 1) the body of the if still checks args[0][1] and
finds that it is out of bounds and rejects it.
with
bug.d(6): Error: array index 1 is out of bounds _param_0[0 .. 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