Void functions cant be used in expression that require a value. Every 'switch' statement should contain non-empty switch-clauses. AUTOSAR. V565. Function always returns the same value of NN. V3100. V543. V2502. This leads to undefined behavior. V1045. The true value (VARIANT_TRUE) is defined as -1. This condition was already verified in previous line. return expressionopt ; The value of expression, if present, is returned to the calling function. MISRA. V643. Update: You need to make your function return a vector in every condition as suggested in comments. 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. Throwing from exception constructor may lead to unexpected behavior. Why do we ask to use Business V1022. Constant expression evaluation should not result in an unsigned integer wrap-around. V580. V1088. V646. Incorrect shifting expression. MISRA. V6066. The initial value of the index in the nested loop equals 'i'. V2587. Cast should not convert a pointer to a function to any other pointer type, including a pointer to function type. As report_square takes no parameters and returns void, we don't assign its result to a variable. Appending an element and checking for key uniqueness is performed on two different variables. return Statement (C) | Microsoft Learn Calling overrideable class member from constructor is dangerous. Microsoft-specific: In the Microsoft C implementation, the long long type is large enough to hold the product of two int values without overflow. So it does not know if the second strlen will return the same value as the first one. Pointer to local variable 'X' is stored outside the scope of this variable. A variable of the memsize type is read from a stream. Pointer to FILE should not be dereferenced. operators are used for accessing members of the same object. MISRA. MISRA. V571. The '//' and '/*' character sequences should not appear within comments. Is the code I've written here adequate to do that? N operand of '? Pointer was used unsafely after its check for nullptr. If total energies differ across different software, how do I decide which software to use? Expressions with pointer type should not be used in the '+', '-', '+=' and '-=' operations. V1001. Incorrect shifting expression. V772. Dozens of bugs have been opened for this . V3044. External object or function should be declared once in one and only one file. V632. Every 'switch' statement should have a 'default' label, which, in addition to the terminating 'break' statement, should contain either a statement or a comment. Several shared_ptr objects are initialized by the same pointer. Suspicious bitwise operation was detected. V654. The 'ThreadStatic' attribute is applied to a non-static 'A' field and will be ignored. A minor scale definition: am I missing something? Unsafe invocation of event, NullReferenceException is possible. Flowing off the end of a non-void function with no 'return' results in undefined behavior. The condition (ptr - const_value) is only false if the value of a pointer equals a magic constant. V3053. V731. Consider inspecting the loop expression. An unconditional 'break/continue/return/goto' within a loop. Expression's value is copied at the variable declaration. V002. Use direct analyzer integration or compiler monitoring instead. Consider checking the N format items of the 'Foo' function. Object created using 'new' operator is immediately cast to another type. V6048. Consider inspecting the expression. Property setter / event accessor does not utilize its 'value' parameter. Same value is present on both sides of the operator. We and our partners use data for Personalised ads and content, ad and content measurement, audience insights and product development. V593. V671. V6053. Insecure XML parser is used to process potentially tainted data. Parameter 'A' is always rewritten in method body before being used. This means that the second 'if' statement is senseless. Suspicious explicit conversion from 'float *' type to 'double *' type. V3175. Numeric Truncation Error. Expression under 'throw' is a potential null, which can lead to NullReferenceException. Function exited without releasing the pointer/handle. V771. A method can return default null value. It is odd that the body of 'Foo_1' function is fully equivalent to the body of 'Foo_2' function. MISRA. V3093. V6004. If the function has a return type other than void, it's a serious bug, and the compiler prints a warning diagnostic message. By cv void, it simply means a function with void return type, that may be const or volatile. However, C doesn't require the parentheses. V2600. Possibly meant: 'A += B'. Extending 'std' or 'posix' namespace may result in undefined behavior. V2606. std::cout doesnt know how to handle this (what value would it output?). V784. There are two 'if' statements with identical conditional expressions. Comparison of arrays, strings, collections by reference. The variable of char type is compared with pointer to string. V3006. rev2023.4.21.43403. V3014. Comma may be missing. Dangerous explicit type pointer conversion. Potentially tainted data is used to create OS command. The value should be non-negative. V3105. V2541. Consider refactoring the 'Foo' function. This may lead to undefined behavior. Fixing "no return statement in function returning non-void" and warning Let's consider an example. MISRA. V657. V637. Logical literal belongs to second operator with a higher priority. This condition was already verified in previous line. operator should have 'bool' type. V1032. Conversions should not be performed between pointer to function and any other type. V5301. Code's operational logic does not correspond with its formatting. Suspicious simultaneous use of bitwise and logical operators. New variable with default value is created instead of 'std::unique_lock' that locks on the mutex. AUTOSAR. Class member is initialized with dangling reference. Perhaps, this statement should have been compared with something else. The language standard does not define order in which 'Foo' functions are called during evaluation of arguments. The object was created but it is not being used. MISRA. V1067. V2523. An odd precise comparison. V5615. Such a pointer will become invalid. MISRA. V3525. MISRA. Postfix increment/decrement is senseless because this variable is overwritten. You can return a value from a Function procedure in any of the following ways: Assign the value to the Function procedure name and then perform an Exit Function statement. Unexpected uint64 behaviour 0xFFFF'FFFF'FFFF'FFFF - 1 = 0? The result will always be zero. Return value is not always used. V2001. Character escape is used in multicharacter literal. objToJSON nonvoid function does not return a value #5326 - Github Excessive type casting: string -> char * -> string. Decreased performance. V6046. Pointer was used in the logical expression before its check for nullptr in the same logical expression. Implicit assignment type conversion to memsize type. The expression was enclosed by parentheses twice: ((expression)). The expression contains a suspicious mix of integer and real types. If a return type isn't specified, the C compiler assumes a default return type of int. WPF: readonly field of 'DependencyProperty' type is not initialized. The reference was used before it was verified against null. V694. MISRA. OWASP. During the initial analysis, the code nominally contains three code paths. V2594. Consider checking for typos. V6023. V3182. V5608. Such a statement will cause the function to return to the caller when the return statement is executed (before the function would otherwise return to the caller, hence, early). V3528. V754. check your Spam/Junk folder and click the "Not Spam" button for our message. Size of an array is not specified. It's probably an error or un-optimized code. V567. V2569. Thanks for helping to make the site better for everyone. Consider using '||' and '&&' instead. V3043. V114. Content Discovery initiative April 13 update: Related questions using a Review our technical responses for the 2023 Developer Survey. V3161. MISRA. Assigning potentially negative or large value as timeout of HTTP session can lead to excessive session expiration time. V2551. V1042. Consider inspecting the expression. The report_ratio function calls ratio with parameter values of 1 and INT_MAX. Consider inspecting this expression. Consider enabling the display of invisible characters in the code editor. MISRA. What's the cheapest way to buy out a sibling's share of our parents house if I have no cash and want to pay less than the appraised value? Some types of expressions require values. V5627. V2571. V3058. WPF: the names of the property registered for DependencyProperty, and of the property used to access it, do not correspond with each other. V511. V3045. 565), Improving the copy in the close modal and post notices - 2023 edition, New blog post from our CEO Prashanth: Community is the future of AI. V680. V711. Consider using a comparison with defined precision: Math.abs(A - B) < Epsilon or Math.abs(A - B) > Epsilon. V786. Assign the value to the Function procedure name and then perform the End Function statement. V2542. The escape sequence ends with a letter and the next character is also a letter. Consider inspecting the 'switch' statement. This leads to the variable binding to a temporary object instead of a range element. Both operands of an operator should be of the same type category. The 'operator &&', 'operator ||', 'operator ,' and the unary 'operator &' should not be overloaded. The return statement may or may not return anything for a void function, but for a non-void function, a return value must be returned. AUTOSAR. V3104. Explicit conversion from 32-bit integer type to pointer type. There should be no occurrence of undefined or critical unspecified behaviour. V828. An array/object was declared but was not utilized. V2510. V2593. Suspicious return of an always empty collection. V2522. Operand of sizeof() operator should not have other side effects. V3009. V6064. OWASP. V832. V1047. The variable 'X' is being used for this loop and for the outer loop. V579. V781. The code's operational logic does not correspond with its formatting. V2546. V3166. Negative value is implicitly converted to unsigned integer type in arithmetic expression. V5619. MISRA. Non-atomic modification of volatile variable. There will be no undefined behavior here. The '? V5621. Consider wrapping the throw operator in a try..catch block. The first 'if' statement contains method return. V709. It is likely that a wrong variable is being incremented inside the 'for' operator. The operator '||' operator is surrounded by opposite expressions 'x' and '!x'. Function with a non-void return type should return a value from all exit paths. The macro with the 'setjmp' name and the function with the 'longjmp' name should not be used. The second function call to function printHi() wont even compile. V582. The 'memset/memcpy' function is used to nullify/copy fields of 'Foo' class. V2563. Loop may execute incorrectly or may not execute at all. V639. Literal suffixes should not contain lowercase characters. The variable is incremented in the loop. 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. 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 . Pointer to an object of the class is cast to unrelated class. One pair of parentheses is unnecessary or typo is present. MISRA. OWASP. The left operand of integer division is less than the right one. to your account, const typename object_t::key_type& key() const V508. V3147. Stack of original exception could be lost. Empirical analysis. Possibly an equality comparison was intended. AUTOSAR. Unreachable code was detected. V3143. hi, at least for bool keyPressed(ofKeyEventArgs& args) it should return false as the default otherwise the event propagation will stop.. in glTypeForImageType(int imageType)I would simply add return 0; at the end of the function. Initial and final values of the iterator are the same. caeser - Getting "non-void function does not return a value in all V665. This may lead to undefined behavior. warning: non-void function does not return a value - YouTube V3172. Dangerous cast of 'this' to 'void*' type in the 'Base' class, as it is followed by a subsequent cast to 'Class' type. Conversions between pointers to objects and integer types should not be performed. Expression of the 'A =+ B' kind is used. MISRA. A value of variable is not modified. Bounds should not contain size of a buffer, but a number of characters it can hold. V107. Consider inspecting this expression. Incorrect type of a loop variable. OWASP. Implicit type conversion to memsize type in an arithmetic expression. Part of conditional expression is always true/false. I compiled a small program containing the following function definition. No more than one iteration of the loop will be performed. V1078. Arrays should not be partially initialized. V1049. Lifetime of the heap-allocated variable is limited to the current function's scope. The square function returns the square of its argument, in a wider type to prevent an arithmetic error. Dangerous construction is used: 'm[x] = m.size()', where 'm' is of 'T' class. It demonstrates the return statement, and how it's used both to end function execution, and optionally, to return a value. The object of non-passive (non-PDS) type cannot be used with the function. See NN argument of function 'Foo' in derived class and base class. V827. The variable is assigned but is not used by the end of the function. Expression resulting from the macro expansion should be surrounded by parentheses. V577. It makes code less human error prone. Many programmers use parentheses to enclose the expression argument of the return statement. V533. Property accessors use different backing fields. OWASP. V2529. More than one sizeof() operator is used in one expression.