Fixing the issue with "Statement unreachable"
Timon Gehr
timon.gehr at gmx.ch
Thu Apr 30 09:10:16 UTC 2020
On 30.04.20 08:00, Walter Bright wrote:
> Evidently, your example must be different from this. Please post a
> complete example.
You need -W. -W also notices the dangling elses, the intended code is this:
bool test(){
static if(condA){
static if(condB){
static if(NEW_CONDITION) return true;
else static if(condC){
if(funA()) return true;
}else static if(condD) {
if(funB()) return true;
}else{
if(funC()) return true;
}
}else static if(condD){
if(funD()) return true;
}else{
if(funE()) return true;
}
}
return false; // Warning: statement is not reachable
}
enum bool condA = true, condB = true, condC = true, condD = true;
enum NEW_CONDITION = true;
bool funA();
bool funB();
bool funC();
bool funD();
bool funE();
More information about the Digitalmars-d
mailing list