If you call the function with a first argument of 0
the loop is never executed and the return
statement is, thus, never reached. Falling of the end of a non-void
function is undefined behavior.
My personal guess is that the return
statement was meant to one level up, i.e., in the out block: this would guarantee that the function always returns a value and the warning would go away.
Related Posts:
- What does “warning: not all control paths return a value” mean? (C++)
- C++ — expected primary-expression before ‘ ‘
- Return array in a function
- Meaning of = delete after function declaration
- How to use _CRT_SECURE_NO_WARNINGS
- libpng warning: iCCP: known incorrect sRGB profile
- invalid use of non-static member function
- Reverse Contents in Array
- c++: No instance of overloaded function
- error: expected primary-expression before ‘)’ token (C)
- libpng warning: iCCP: known incorrect sRGB profile
- error: “initializer expression list treated as compound expression”
- Getting error: ISO C++ forbids declaration of with no type
- Function for C++ struct
- c++ –
- What does it mean that “a declaration shadows a parameter”?
- C++ – statement cannot resolve address for overloaded function
- How do I return a char array from a function?
- How to return a struct from a function in C++?
- Why can’t we pass arrays to function by value?
- template argument deduction/substitution failed, when using std::function and std::bind
- C++ Void Function with File Stream Error
- variable or field declared void
- Warning : overflow in implicit constant conversion
- function does not take 1 arguments c++
- C++ correct way to return pointer to array from function
- Difference between function arguments declared with & and * in C++
- Is C++ Array passed by reference or by pointer?
- “cannot be used as a function error”
- How to create a dynamic array of integers
- How to implement 2D vector array?
- What is the difference between g++ and gcc?
- What is the best way to use a HashMap in C++?
- What is the difference between float and double?
- What’s the C++ version of Java’s ArrayList
- What is the difference between “long”, “long long”, “long int”, and “long long int” in C++?
- ‘g++’ is not recognized as an internal or external command, operable program or batch file
- How do I convert a double into a string in C++?
- How to create timer events using C++ 11?
- How to concatenate two strings in C++?
- ‘g++’ is not recognized as an internal or external command, operable program or batch file
- Read file line by line using ifstream in C++
- Virtual/pure virtual explained
- error: redefinition of class
- Officially, what is typename for?
- C++ Parsing input string to variables
- ‘cout’ was not declared in this scope
- Segmentation fault error 11 C++
- Why doesn’t C++ have a garbage collector?
- How does ifstream’s eof() work?
- terminate called after throwing an instance of ‘std::invalid_argument’ what(): stoi
- How to find memory leak in a C++ code/project?
- libstdc++-6.dll not found
- vector
::size_type in C++ - What does ‘\0’ mean?
- cin >> “no operator matches these operands”
- C++ on mac : linker command failed with exit code 1 (use -v to see invocation)
- Correct way to use cin.fail()
- Destructor for a linked List
- Why use a new call with a C++ ‘vector’?
- Identifier is undefined
- How to end C++ code
- Delete 2D array C++
- class not declared in scope – even though .h was included
- Best C/C++ Network Library
- How to check that an element is in a std::set?
- Best way to extract a subvector from a vector?
- How do malloc() and free() work?
- C++ string to enum
- c++ “Incomplete type not allowed” error accessing class reference information (Circular dependency with forward declaration)
- why is string not declared in scope
- How does rhs work?
- error: expected unqualified-id before ‘.’ token //(struct)
- Base class undefined
- C++ – Assigning null to a std::string
- The program can’t start because libgcc_s_dw2-1.dll is missing
- C++ – Too Many Initializers for Arrays
- G++ undefined reference to class::function
- Is string::compare reliable to determine alphabetical order?
- C++ printing boolean, what is displayed?
- Error : aggregate ‘first one’ has incomplete type and cannot be defined
- CMake : C and CXX compiler identification is unknown Win10 CMakeGUI
- Error “Unterminated conditional directive” in cross-referencing headers
- C++ template – error: expected initializer before ‘<' token
- Error in assignment of member in read-only object
- creating an array of structs in c++
- What’s the Use of ‘\r’ escape sequence?
- How do I use an enum value in a switch statement in C++?
- Why should I use a pointer rather than the object itself?
- overloaded function with no contextual type information
- How exactly do lookup tables work and how to implement them?
- Vector declaration “expected parameter declarator”
- C++ Destructors with Vectors, Pointers,
- Return a 2d array from a function
- Linker error: “linker input file unused because linking not done”, undefined reference to a function in that file
- What is the difference among ios::app, out, and trunc in c++?
- Where can I find ‘winmm.lib’ (I’m using Visual Studio 2012)
- What is a `char*`?
- Does static constexpr variable inside a function make sense?
- “Incomplete type not allowed ” when creating std::ofstream objects