V1064. Void functions dont need a return statement. What were the poems other than those by Donne in the Melford Hall manuscript? Consider inspecting the condition. Identifiers that start with '__' or '_[A-Z]' are reserved. The value is assigned to the 'x' variable but is not used. This means that the second 'if' statement is senseless. The 'then' statement is equivalent to the 'else' statement. More than N bits are required to store the value, but the expression evaluates to the T type which can only hold K bits. Consider inspecting the condition for mistakes. This file is marked with copyleft license, which requires you to open the derived source code. Strings were concatenated but not used. V3538. OWASP. After the year 2038, the program will work incorrectly. Collection is modified while iteration is in progress. V1011. Function result is saved inside the 'byte' type variable. operators are used for accessing members of the same object. Recurring check. V2504. V2507. V3052. Parameter 'A' is always rewritten in method body before being used. Arguably, this is a shortcoming in the compiler. Suspicious type conversion: HRESULT -> BOOL (BOOL -> HRESULT). AUTOSAR. MISRA. The code fragment is equivalent to the following: Note that undefined behavior occurs only if the end of a non-void function is actually reached. MISRA. V1081. It calls strlen once and either jumps to .L1 or falls through to the then code, which rejoins at .L1. Consider assigning event to a local variable before invoking it. Consider making it implement 'IDisposable' interface. V566. Inappropriate attempt to append a null character to a string. Octal and hexadecimal escape sequences should be terminated. V1088. Empty exception handler. Result of this expression will be implicitly cast to 'Type'. OWASP. Consider inspecting signed and unsigned function arguments. Comparison of arrays, strings, collections by reference. Trying to return a value from a non-value returning function will result in a compilation error: A return statement that is not the last statement in a function is called an early return. Consider using of 'if-else' construct. Declaration should contain no more than two levels of pointer nesting. If you wish to call constructor, use 'this->Foo::Foo(.)'. V6037. is there a trick to keep in mind when adding your own JSON_THROW? V752. Unchecked tainted data is used in expression. The standard input/output functions should not be used. Consider inspecting the expression for function call. V3103. Check lines: N1, N2. rev2023.4.21.43403. OWASP. The double result is stored in fraction, then printed. Cast should not remove 'const' / 'volatile' qualification from the type that is pointed to by a pointer or a reference. I am writing a function to validate if the strlen of a string = 26 or not and returning a boolean value however I get an error message stating "error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]" despite there being no way for a value not to be returned. V6058. Conditional escape sequence in literal. Consider inspecting the 'foo' function. error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]} bool is_full() { if() { return 1; } else if() { return 0; } else if() { return 1; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 : It is not advised to declare type 'T' as 32-bit type. Consider inspecting the expression. An item with the same key has already been added. Decreased performance. V6078. Consider checking for typos. The closing tag was encountered, while the tag was expected. Three potential reasons for issue the warning (elevated to an error) in spite of this come to mind: Nonetheless, this is easy to work around. Compound assignment expression is used inside condition. Variable is declared as auto in C. Its default type is int. V205. Extracting arguments from a list of function calls. Then the return statement is executed, returning the value of 5 back to the caller. What differentiates living as mere roommates from living in a marriage-like relationship? It is not recommended to throw exceptions from 'Equals(object obj)' method. Code's operational logic does not correspond with its formatting. V2524. V6006. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. It is possible that an assigned variable should be checked in the next condition. Range intersections are possible within conditional expressions. It is possible that a wrong variable is incremented inside the 'for' operator. MISRA. Consider using 'i + 1' instead. V540. V631. Consider inspecting the expression. The result of '&' operator is always '0'. Can the game be left in an invalid state if all state-based actions are replaced? V2564. Call 'Dispose' when disposing 'A' class. V2510. V2519. The 'if' 'else if' construct should be terminated with an 'else' statement. V6023. Variable is not used after memory is allocated for it. What risks are you taking when "signing in with Google"? Check if program logic handles it correctly. V507. The sizeof() operator is multiplied by sizeof(). MISRA. V301. The 'Foo' function receives class-type variable as 'N'th actual argument. Update: You need to make your function return a vector in every condition as suggested in comments. V704. Perhaps, this is a typo and 'X' variable should be used instead of 'Y'. This may lead to undefined behavior. however, it floods the compiler output. The return value of non-void function should be used. Do not define an unnamed namespace in a header file. Looking at the assembly GCC 11.2 generates for this with -O3, we see it has in fact recognized that the union of all cases in the if and else if covers all possibilities: It has generated only two code paths, not three. V835. V5603. V6055. The 'goto' statement shouldn't jump to a label declared earlier. OWASP. V664. Without re-registering for finalization, destructor will not be called a second time on resurrected object. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. V3055. The Ctor(SerializationInfo, StreamingContext) constructor is missing. Condition of a loop is always true/false. V628. V6029. The 'zero' value is assigned to pointer. V3134. Possible Zip Slip vulnerability. I recently fixed something similar in #2898 which is not yet merged. V534. The left operand of integer division is less than the right one. The object is already of the same type. V1006. V658. V615. V5618. Consider inspecting the loop expression. Consider using the 'Ptr' version of the 'foo' function here. Potentially tainted data is processed by regular expression that contains an unsafe pattern. Locking operations must be performed on the same thread. V767. V2622. V3006. The identifier 'main' should not be used for a function other than the global function 'main'. V6100. Interpreting non-statistically significant results: Do we have "no evidence" or "insufficient evidence" to reject the null? Incorrect index type: 'foo[not a memsize-type]'. An array/object was declared but was not utilized. V738. MISRA. MISRA. The function was annotated as dangerous. Macro name overrides a keyword/reserved name. Such a function results in undefined behavior. Consider making the project fully compilable and building it before analysis. Potentially tainted data is used to create an object using deserialization. It is suspicious that a char or string literal is added to a pointer. OWASP. V530. Consider inspecting the expression. Unions should not be used. V3186. V3032. Classes should not be compared by their name. Suspicious simultaneous use of bitwise and logical operators. V521. V6089. V2583. Expression was implicitly cast from integer type to real type. V1077. Parameter is not utilized inside method's body. Let's consider an example. The 'bar2.h' header will be excluded from compilation. V532. Consider inspecting the application's logic. The body of a loop\conditional statement should be enclosed in braces. AUTOSAR. V5008. N argument has memsize type. V3027. V3060. V107. V596. The loop counter should not have floating-point type. nlohmann/json.hpp:20925:5: warning: non-void function does not return a value in all control paths [-Wreturn-type], const_reference operator[](const typename object_t::key_type& key) const V732. One is enough. WPF: the type registered for DependencyProperty does not correspond with the type of the property used to access it. Possible null dereference. V789. How to Make a Black glass pass light through it? V605. This condition was already verified in previous line. Potential division by zero. Value of a variable is checked after it is used. The name of 'X' field/property in a nested type is ambiguous. V739. V2604. Consider inspecting the expression. V3520. I am interested to try it on Make sure the expression is correct. It is possible that an incorrect variable is compared with null after type conversion using 'dynamic_cast'. One of the operands in the operation equals NN. The 'continue' operator will terminate 'do { } while (FALSE)' loop because the condition is always false. Dangerous construction is used: 'm[x] = m.size()', where 'm' is of 'T' class. You are assuming that loop will always run, but, what if an empty string ends up getting submitted? Check the shift operator. V3086. Decreased performance. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. V3516. V3153. Which language's style guidelines should be used when writing code that is supposed to be called from another language? Consider adding the 'cin.fail()' function call to the conditional expression. Potentially tainted data is used in the path toextractthe file. MISRA. AUTOSAR. Number of elements in the allocated array equals the size of a pointer in bytes. V2562. Two or more case-branches perform the same actions. V5619. The object was created but it is not being used. OWASP. V126. V786. MISRA. V6071. My statement was question specific. 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. V2509. V2601. P.S. All memory or resources allocated dynamically should be explicitly released. Literal suffixes should not contain lowercase characters. V2578. V1078. Every switch-clause should be terminated by an unconditional 'break' or 'throw' statement. Try to avoid many return statements in your code. A double memory deallocation will occur. V2532. V1041. V1021. The 'switch' statement should have 'default' as the last label. The original exception object was swallowed. V824. MISRA. Decreased performance. OWASP. MISRA. Such absolute value can't be represented in two's complement. Consider checking the use of this variable. Use filter buttons or 'Don't Check Files' settings to enable message display. V111. Value of a composite expression should not be cast to a different essential type category or a wider essential type. It is possible that ',' comma is missing at the end of the string. It is possible that '1' should be present instead of '0'. Consider creating a 'T' type object. V3119. Consider using 'i + 1' instead. V1049. 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. The arguments violate the bounds of collection.