warning non void function does not return a value
Passing cheap-to-copy argument by reference may lead to decreased performance. Member invocation on this value may lead to an exception. Consider inspecting the loop expression. An odd sequence of assignments of this kind: A = B; B = A; V3038. Consider inspecting the expression for function call. V6104. Consider using 'std::move' instead. V809. The right operand is greater than or equal to the number of bits in the left operand. V6021. Possible meaningless check for null, as memory was allocated using 'new' operator. Consider inspecting the expression. MISRA. It is not recommended to return null or throw exceptions from 'ToString()' method. V3171. V560. V004. Otherwise, the integer division operator would be used, and the fractional part would be lost. V1041. The 'A' function was called several times with identical arguments. The default is -Wunused-result. Functions should not have unused parameters. . : .' should be used here instead of 'foo = bar = baz ? V831. Consider using a comparison with defined precision: Math.abs(A - B) < Epsilon or Math.abs(A - B) > Epsilon. Do not define an unnamed namespace in a header file. Waiting on this expression is unreliable, as compiler may optimize some of the variables. V3168. V1078. Unsafe invocation of event, NullReferenceException is possible. V6071. V2509. V2015. V3137. Storing credentials inside source code can lead to security issues. V621. AUTOSAR. A terminal null is present inside a string. MISRA. It is dangerous to create a local variable within a loop with a same name as a variable controlling this loop. AUTOSAR. Potentially tainted data is used to create OS command. A code fragment from 'file' cannot be analyzed. V751. Was Aristarchus the first to propose heliocentrism? V3092. Remember that members are initialized in the order of their declarations inside a class. V680. Consider inspecting the 'for' operator. A boy can regenerate, so demons eat him for years. V6077. A switch-label should only appear at the top level of the compound statement forming the body of a 'switch' statement. Potential division by zero. V671. The '+' operation is executed. The '&=' or '|=' operator is redundant because the right operand is always true/false. Violated order of exception handlers. Content Discovery initiative April 13 update: Related questions using a Review our technical responses for the 2023 Developer Survey, Non-void function does not return a value. V1096. Decreased performance. Consider inspecting the 'switch' statement. Make sure the expression is correct. It is possible that 'foo = bar == baz ? V645. If expression is omitted, the return value of the function is undefined. Use of 'Foo' uninitialized variable. Only the first element is initialized explicitly. Generic Doubly-Linked-Lists C implementation. V668. It is likely that a wrong variable is being incremented inside the 'for' operator. V3535. So, the compiler generates an error. Consider using the 'int' type. V3062. V734. V2008. V5006. Call of the 'Foo' function will lead to buffer underflow. V3027. Its representation is implementation-defined. V1053. Inspect the program's logic. Consider refactoring the code. Some types of expressions require values. The '#pragma warning(push/pop)' should be used instead. V3516. Assign the value to the Function procedure name and then perform an Exit Function statement. Why does Acts not mention the deaths of Peter and Paul? V6061. Class defines a custom new or delete operator. Memory allocation will lead to an exception. The 'cin.eof()' condition is insufficient to break from the loop. V3151. Size of an array is not specified. Use volatile variable(s) or synchronization primitives to avoid this. Void functions dont need a return statement. :' operator. V3045. V776. Probably the '!=' should be used here. The report_square function calls square with a parameter value of INT_MAX, the largest signed integer value that fits in an int. The variable is incremented in the loop. to your account, const typename object_t::key_type& key() const We and our partners use data for Personalised ads and content, ad and content measurement, audience insights and product development. AUTOSAR. The 'alloca' function is used inside the loop. Consider inspecting the expression. The code can be rewritten as either: Although you report testing the former option, GCC will not report the warning in this case, so I believe your test was faulty, such as compiling code other than what you intended to compile. The '? V205. V833. V646. Property accessors use different backing fields. Identical expression to the left and to the right of compound assignment. V6036. V3117. V725. The global namespace should only contain 'main', namespace declarations and 'extern "C"' declarations. V3554. It's possible that ',' should be replaced by ';'. BSTR string becomes invalid. AUTOSAR. It is suspicious that the BSTR data type is compared using a relational operator. Regression: objToJSON "nonvoid function does not return a value" error is back #31463 Closed pkaleta mentioned this issue on Jun 24, 2020 BUG: NUMPY_IMPORT_ARRAY_RETVAL undeclared when installing pandas 0.18.1 #34969 Closed Sign up for free to join this conversation on GitHub . Consider using the 'size()' function. Every 'switch' statement should have a 'default' label, which, in addition to the terminating 'break' statement, should contain either a statement or a comment. V3524. V3179. Probably the '-=' should be used here. V5007. V2011. V2588. V3521. V6076. A 'wchar_t *' type string is incorrectly converted to 'BSTR' type string. V3036. The DllMain function throws an exception. Probably meant: '\xNN'. The value should be non-negative. Suspicious explicit type casting. The initial value of the index in the nested loop equals 'i'. There is an easy solution to the problem, even if we understand that every condition is covered we should add a return statement at the end of the function so the compiler is sure that the non-void function will be returning some value. Defining an absolute path to the file or directory is considered a poor style. V733. I will edit. V1002. MISRA. The expression was implicitly cast from integer type to real type. The size of the dynamic array can be less than the number of elements in the initializer. I did return true and false but its still giving me this error [deleted] 2 yr. ago More posts you may like V2556. Consider inspecting the expression. Why do we ask to use Business Two similar code fragments. Functions are not required to return a value back to the caller. Many programmers use parentheses to enclose the expression argument of the return statement. Constant expression in switch statement. It may happen that flow is never reaching that part of the code but it is important to write for the compiler. V626. "non-void function does not return a value in all control paths". V3032. Probably meant 'A[B] < C'. If control passes to Exit Function or End Function and you have not assigned any value to the procedure name, the procedure returns the default value of the return data type. Please check projects and solution configurations. The '? Unsafe double-checked locking. Potentially unsafe double-checked locking. V717. V5003. A more efficient way is to check: str[0] != '\0'. V3161. One pair of parentheses is unnecessary or misprint is present. V008. V2576. Parameter 'A' is always rewritten in method body before being used. V009. V1085. AUTOSAR. Silent suppression of exceptions can hide errors in source code during testing. OWASP. It's possible that 'else' keyword is missing. Operands of the logical '&&' or the '||' operators, the '!' MISRA. AUTOSAR. MISRA. Modified value of the operand is not used after the increment/decrement operation. jump-statement: V3024. Function receives an address of a 'char' type variable instead of pointer to a buffer. When main calls printHi, the code in printHi executes, and Hi is printed. V3128. It is more efficient to catch exception by reference rather than by value. All memory or resources allocated dynamically should be explicitly released. Inspect the following programs and state what they output, or whether they will not compile. V1093. Loop break conditions do not depend on the number of iterations. Possible exception when serializing type. V817. If no return statement appears in a function definition, control automatically returns to the calling function after the last statement of the called function is executed. All I want the function to do is add one to the value of the each character inputted into the string array and shift it on the ASCII table and then return the coded message. V3178. V657. Suspicious subexpression in a sequence of similar comparisons. Save the file, and compile it in a Developer command prompt window by using the command: Then, to run the example code, enter C_return_statement.exe at the command prompt. Functions should not have unused parameters. V3520. V3136. Abnormality within similar comparisons. An item with the same key has already been added. Explicit conversion from memsize type to 32-bit integer type. V836. TYPE X[][] is not equivalent to TYPE **X. Notice that BSTR strings store their length before start of the text. The value of uninitialized variable should not be used. A bool type variable is incremented. Examine the substrings "abc" and "abcd". V3025. Variables are initialized through the call to the same function. V552. V1033. MISRA. Thanks for contributing an answer to Stack Overflow! A switch-expression should not have Boolean type. Consider inspecting the expression. Consider checking the use of this variable. The 'X' counter is not used inside a nested loop. V735. V2001. V702. AUTOSAR. V3066. OWASP. An excessive type cast or check. A 32-bit variable is utilized as a reference to a pointer. A thread can wait indefinitely or experience a spurious wake-up. So far, we never make a pedantic check with exceptions switched off. V2575. V3517. V2511. The expression was enclosed by parentheses twice: ((expression)). The analyzer is unable to determine the position where this argument is modified. OWASP. Expression containing increment (++) or decrement (--) should not have other side effects. V5011. It is possible that an error is present. V773. triniChillibibi 2 yr. ago This was for my print_winner function in runoff. V627. the platforms: Continuous use of the analyzer in software development, Deploying the analyzer in cloud Continuous Integration services, Additional configuration and resolving issues. The left operand of integer division is less than the right one. MISRA. The statement std::cout << "B" is never executed because the function has returned to the caller prior to that point. AUTOSAR. The expression is checked for compatibility with the type 'A', but is casted to the 'B' type. There are two 'if' statements with identical conditional expressions. MISRA. V1071. Both paths return a value. V685. Inspect the Nth argument. Variable is not used after memory is allocated for it. The SUCCEEDED or FAILED macro should be used instead. V2535. Suspicious literal: '/r'. Size of array calculated by sizeof() operator was added to a pointer. So it does not know if the second strlen will return the same value as the first one. Learn more about Stack Overflow the company, and our products. @Sneftel Good point. V738. Compiler may delete 'memset' function call that is used to clear 'Foo' buffer. Custom declaration of standard type. A function should have a single point of exit at the end. Currently your code is returning the vector based on conditions. V3140. MISRA. See NN argument of function 'Foo' in derived class and base class. V109. Possible null dereference. Content Discovery initiative April 13 update: Related questions using a Review our technical responses for the 2023 Developer Survey. It calls strlen once and either jumps to .L1 or falls through to the then code, which rejoins at .L1. No locking will be performed. V2503. V3004. The alignment rules and type sizes have been changed. Consider inspecting the expression. If you haven't received our response, please do the following: check your Spam/Junk folder and click the AUTOSAR. It is possible that '1' should be present instead of '0'. The standard signal handling functions should not be used. V1073. So GCC knows there is no possible control path that does not return a value, but it reported the warning (elevated to an error) anyway. V3547. Possible incorrect order of arguments passed to function.