[ale] C++ "not all control paths return a value"
    Benjamin Scherrey 
    scherrey at proteus-tech.com
       
    Fri Jan 28 16:53:06 EST 2005
    
    
  
Comments intermixed in your code...
Jay Loden wrote:
> I've got some code that compiles, but with a warning for the following 
> function:
>
> string truncPath(string name){
>    if(name.substr(1, 1) == ":"){
>        for(int k=0; k < 30; k++){
>            if(name.substr(name.length()-k, 1) == "\\"){
>                string ret = name.substr(name.length()-k+1, k);
>                return ret;
>            }
>        }
          // Your flow of control could logically get here which would 
result in no return value.
>    }
>
       // Best solution is just to get rid of this else clause because 
if the above return
       // doesn't get executed then you always want 'return name;' to 
happen, right?
>    else{
>        return name;
>    }
> }
>
> Saying "Not all control paths return a value" - what does this mean, 
> am I missing something in my code?
>
> -Jay
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
    
    
More information about the Ale
mailing list