V817. Temporary object is created and then destroyed. Functions should be declared in prototype form with named parameters. Bit shifting of the 32-bit value with a subsequent expansion to the 64-bit type. V6017. V681. Pointer to an object of the class is cast to unrelated class. Member operator[] of 'foo' class has a 32-bit type argument. Variable should be declared in a scope that minimizes its visibility. He also rips off an arm to use as a sword. Expression 'A = B == C' is calculated as 'A = (B == C)'. The function is used as if it returned a bool type. Consider inspecting the program's logic. The 'Foo' function receives class-type variable as 'N'th actual argument. V6050. It is possible that the number of elements should be calculated by sizeof(A)/sizeof(A[0]). V750. V622. Expressions with enum underlying type should have values corresponding to the enumerators of the enumeration. Probably it is a mistake. A function should not call itself either directly or indirectly. The '#pragma warning(push/pop)' should be used instead. V672. Therefore, printHi is given a void return type. V833. V6102. the first printHi() in the above example), were calling a function for its behavior, not its return value. Suspicious literal: '/r'. The 'throw' operator does not have any arguments and is not located within the 'catch' block. V3044. V2520. It is possible that a backslash should be used instead: '\r'. Return value of 'Foo' function is required to be used. The result should possibly be saved to a temporary variable, which then could be used while calling the 'B' function. Suspicious code formatting. V5005. MISRA. V2538. However, C doesn't require the parentheses. Value is subtracted from unsigned variable. Decreased performance. V641. This may lead to ODR violation. He also rips off an arm to use as a sword. V3059. rev2023.4.21.43403. It is safer to use the 'foo' function. Potentially tainted data is used to create an object using deserialization. OWASP. MISRA. Assign the value to the Function procedure name and then perform an Exit Function statement. Probably meant: '(*pointer)++'. V3094. AUTOSAR. The opportunity to suppress the warning was overlooked. String is printed into itself. The macro with the 'setjmp' name and the function with the 'longjmp' name should not be used. [Serializable] attribute is missing. Interpreting non-statistically significant results: Do we have "no evidence" or "insufficient evidence" to reject the null? Overflow check is incorrect. Parameter of 'CancellationToken' type is not used inside function's body. It is suspicious that the result of the statement is a part of the condition. The standard input/output functions should not be used. Consider making it implement 'IDisposable' interface. Error message contains potentially sensitive data that may be exposed. We will email you at. The value of uninitialized variable should not be used. V2522. V588. Size of array calculated by sizeof() operator was added to a pointer. The expression is incorrect or it can be simplified. If expression is omitted, the return value of the function is undefined. OWASP. V2006. There is a probability of logical error presence. The 'X' counter is not used inside a nested loop. Consider replacing 'const T' with 'const .. &T' / 'const .. *T'. It is possible that a call to 'Start' method is missing. Why are players required to record the moves in World Championship Classical games? Operand of sizeof() operator should not have other side effects. V6091. The expression is incorrect or can be simplified. Incorrect format. V657. V1059. For more information on hiding warnings or treating warnings as errors, see Configuring Warnings in Visual Basic. Void functions cant be used in expression that require a value. Consider reviewing the source code that uses the container. V3543. V3009. Here's the correct version: The 'main' and 'wmain' functions are the exceptions. Function always returns the same value of NN. Historically, early returns were frowned upon. V2622. EOF should not be compared with a value of the 'char' type. The functions from time.h/ctime should not be used. The 'X' variable was not initialized. Compound assignment expression 'X += X + N' is suspicious. Do not concatenate string literals with different prefixes. V2591. Passing cheap-to-copy argument by reference may lead to decreased performance. The 'x' variable is assigned values twice successively. AUTOSAR. Thus, the warning is a very useful one and you should consider yourself lucky that the compiler noticed the bug. Suspicious sequence of assignments: A = B; B = A;. Cannot determine active configuration for project. nlohmann/json.hpp:11996:5: warning: non-void function does not return a value in all control paths [-Wreturn-type], static ReferenceType get_ref_impl(ThisType& obj) V006. Handling of two different exception types is identical. V636. V204. It is possible that a typo is present inside the expression. An argument containing a file path could be mixed up with another argument. Check lines: N1, N2. Assigning potentially negative or large value as timeout of HTTP session can lead to excessive session expiration time. MISRA. Every 'switch' statement should contain non-empty switch-clauses. BSTR string becomes invalid. A value-returning function should include a return statement, containing an expression. Consider inspecting usage of 'Y' counter. Congratulations! V2616. V579. It is possible that an error is present. Possibly an equality comparison was intended. The best answers are voted up and rise to the top, Not the answer you're looking for? . : .' should be used here instead of 'foo = bar = baz ? Consider inspecting the condition. The analyzer has detected a non-void function with an execution path that does not return a value. The resulting value is meaningless and should not be used. Here is my code: why does it show compile error?? V829. Constructor parameter is not used. Consider replacing the expression 'AA' with 'BB'. More than one sizeof() operator is used in one expression. Suspicious sequence of types castings: pointer -> memsize -> 32-bit integer. The expression contains a suspicious mix of integer and real types. V3089. Use volatile variable(s) or synchronization primitives to avoid this. V3123. OWASP. V594. MISRA. Expression is equivalent to moving one unique pointer to another. No return statement is required. V3004. V511. If you haven't received our response, please do the following: check your Spam/Junk folder and click the Throwing from exception constructor may lead to unexpected behavior. Referenced package contains vulnerability. V6057. Use of uninitialized variable 'Foo'. V608. OWASP. C compiling Error: non-void function does not return a value in all control paths - CS50. The 'else' keyword may be missing. V553. For example: In the above example, the printHi function has a useful behavior (it prints Hi) but it doesnt need to return anything back to the caller. A pointer/reference parameter in a function should be declared as pointer/reference to const if the corresponding object was not modified. V5605. Possible exception: type marked by [Serializable] contains non-serializable members not marked by [NonSerialized]. The sizeof() operator is multiplied by sizeof(). Destructor of 'Foo' class is not declared as virtual. Usage of a suspicious mutex wrapper. MISRA. V673. V3100. V630. std::cout), a value must be provided. A void function will automatically return to the caller at the end of the function. If no value is provided, the compiler will produce a syntax error. V1051. Is it safe to publish research papers in cooperation with Russian academics? V1030. The 'strcmp' function returns 0 if corresponding strings are equal. V2551. V3020. This may lead to undefined behavior. Implicit type conversion from memsize to double type or vice versa. V782. V3007. V6093. Suspicious declaration. V726. V3060. The passing of data to or from this function may be affected. It is more effective to use the prefix form of ++it. Comparison of arrays, strings, collections by reference. An odd sequence of assignments of this kind: A = B; B = A; V3038. GCC options: warning on non-void functions without a return statement, Type No return, in function returning non-void, no return in function using switch statement, No return statement warning in function returning non-void. Unsigned value is compared to the NN number. It's possible that the line was commented out improperly, thus altering the program's operation logics. V2556. V2516. Why do we ask to use Business V2590. Has the Melford Hall manuscript poem "Whoso terms love a fire" been attributed to any poetDonne, Roe, or other? A private Ctor(SerializationInfo, StreamingContext) constructor in unsealed type will not be accessible when deserializing derived types. An identifier with array type passed as a function argument should not decay to a pointer. V3096. V3002. Perhaps, 'ThenBy' should be used instead. V2600. Possible path traversal vulnerability. V3076. Function '' doesn't return a value on all code paths. Exceptions raised inside noexcept functions must be wrapped in a try..catch block. Further, testing by changing the function return type to int and changing the returns to 0 in the then code, 1 in the else if code, and 2 outside that shows assembly code that only returns 0 or 1, proving GCC was not just collapsing the third path into undefined behavior; it outright eliminates it because it is not possible. V5602. V3534. You are assuming that loop will always run, but, what if an empty string ends up getting submitted? MISRA. V5625. Expression contains a suspicious mix of integer and real types. The behavior is undefined for arithmetic or comparisons with pointers that do not point to members of the same array. The closing tag was encountered, while the tag was expected. V778. V3082. Asking for help, clarification, or responding to other answers. Return value of 'wcslen' function is not multiplied by 'sizeof(wchar_t)'. V3165. The opposite operator must also be defined. One of closing ')' parentheses is probably positioned incorrectly. 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. Consider inspecting the expression. A function should have a single point of exit at the end. The expression is checked for compatibility with type 'A', but is cast to type 'B'. Its priority is lower than priority of other operators in its left part. V010. No handlers will be unsubscribed, as a separate delegate instance is created for each anonymous function declaration. V3537. V614. One, the C standard specifies the behavior of, C error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type], the assembly GCC 11.2 generates for this with, testing by changing the function return type to int and changing the returns to, How a top-ranked engineering school reimagined CS curriculum (Ep. Identical expression to the left and to the right of compound assignment. The 'then' statement is equivalent to the 'else' statement. V3138. The compiler makes no such assumptions, so you need to make sure that there is a return path that will be followed if the return statement inside your loop is never reached. V3528. V2603. V3081. The function expects the file to be opened in one mode, but it was opened in different mode. OWASP. Class defines a custom new or delete operator. The 'foo' include guard is already defined in the 'bar1.h' header. V3105. Check lines: N1, N2. A bool type variable is incremented. In such a case, the comparison operation may behave unexpectedly. In the above example, when print() executes, it will first print A. How to Make a Black glass pass light through it? MISRA. A 32-bit variable is utilized as a reference to a pointer. MISRA. V6105. V3151. The variable is never modified. Cast should not convert pointer to function to any other pointer type. V5618. Consider using a comparison with defined precision: fabs(A - B) < Epsilon or fabs(A - B) > Epsilon. Size of an array is not specified. MISRA. AUTOSAR. Function should not contain labels not used by any 'goto' statements. N operand of '? V534. Use memsize-type here. MISRA. V110. It is likely that a wrong variable is being compared inside the 'for' operator. V2517. V6066. Classes should not be compared by their name. MISRA. Not the answer you're looking for? Object was created but not used. AUTOSAR. WPF: A class containing registered property does not correspond with a type that is passed as the ownerType.type. Do not define an unnamed namespace in a header file. V3181. P.S. The function was annotated as dangerous. Presence of #line directives may cause some diagnostic messages to have incorrect file name and line number. 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 Same value is present on both sides of the operator. MISRA. V1053. V615. Perhaps a short-circuit operator should be used instead. 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. You are assuming that loop will always run, but, what if an empty string ends up getting submitted? Expression was implicitly cast from integer type to real type. V2544. Appending an element and checking for key uniqueness is performed on two different variables. V6023. Probably meant: (T1)((T2)a + b). AUTOSAR. The 'goto' statement shouldn't jump to a label declared earlier. Perhaps, this is a typo and 'X' variable should be used instead of 'Y'. Functions should not have unused parameters. Decreased performance. V6081. Youll need to comment out this line of code in order to make your code compile. V5303. It may happen that flow is never reaching that part of the code but it is important to write for the compiler. An exception handling block does not contain any code. Modified value of the operand is not used after the increment/decrement operation. Find centralized, trusted content and collaborate around the technologies you use most. MISRA. Initial and final values of the iterator are the same. A function that does not return a value is called a non-value returning function (or a void function ). It is suspicious that the argument of sizeof() operator is the expression. If you have a C++ program missing a return statement from a function that is supposed to return a value, g++ will compile it happily with no errors (or even a warning, unless -Wreturn-type or -Wall is used). V656. The expression is always false. V665. The value should be non-negative. Lowercase 'L' at the end of a long literal can be mistaken for '1'. V3168. V818. V3079. rev2023.4.21.43403. Consider creating a pointer/reference to avoid using the same expression repeatedly. V2531. V3065. V746. An unconditional 'break/continue/return/goto' within a loop. The variable from the loop exit condition does not change its value between iterations. Parameter is not used inside method's body. The operator '||' operator is surrounded by opposite expressions 'x' and '!x'. MISRA. V1045. V6079. It only takes a minute to sign up. Passing objects of incompatible types to the method of collection. 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). Value from the uninitialized optional is used. V108. Which ability is most related to insanity: Wisdom, Charisma, Constitution, or Intelligence? Unary minus operator does not modify a bool type value. MISRA. Here is a full example. MISRA. No objects are passed to the 'std::scoped_lock' constructor. Check for missing parentheses or use the '&&' or '||' operator. Consider using an explicit type cast to avoid overflow or loss of a fractional part. V3159. (This const / volatile distinction is not important.) V6047. String literal contains potential interpolated expression. Consider inspecting it for a possible error. Expression used in condition should have essential Boolean type. Microsoft-specific: The Microsoft C implementation returns the expression value to the process that invoked the program, such as cmd.exe. A write outside the bounds of this variable may occur. Incorrect index type: 'foo[not a memsize-type]'. V695. This way, you won't miss messages from our team in the future. Functions are not required to return a value back to the caller. The '?.' N argument has memsize type. V638. Possible null dereference. More than N bits are required to store the value, but the expression evaluates to the T type which can only hold K bits. V3515. One of the operands in the operation equals NN. Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. The 'Foo' pointer is always not equal to NULL. Consider replacing this function with 'std::uncaught_exceptions'. Check for missing 'throw' keyword. V779. OWASP. MISRA. V2559. V703. V3545. V2605. V6098. The 'first' argument of 'Foo' function is equal to the 'second' argument. V1056. V2563. Make this option control the pedwarns that don't have any option. V3153. V3188. Macro should not be defined with the same name as a keyword. Suspicious bitwise operation was detected. V836. Program contains an unused label and function call: 'CC:AA()'. It's better to use '= default;' syntax instead of empty body. However, in modern programming they are more accepted, particularly when they can be used to make a function simpler, or are used to abort a function early due to some error condition. V648. A Function procedure has at least one possible path through its code that does not return a value. V3542. V3523. V688. V6043. Unity Engine. i'm not sure if this is intentional behavior. Variables are initialized through the call to the same function. V745. It is suspicious that the value 'X' of HRESULT type is compared with 'Y'. The argument of the method is not expected to be null. MISRA. Pointer was used in the logical expression before its check for nullptr in the same logical expression. V571. It's possible that 'else' keyword is missing. V2018. If you haven't received our response, please do the following: V550. Understanding the probability of measurement w.r.t. The reference was used before it was verified against null. AUTOSAR. Do not use real-type variables as loop counters. The 'i' variable should probably be incremented instead of the 'n' variable. Consider inspecting the expression. V205. AUTOSAR. Floating-point values should not be tested for equality or inequality. Check for typos. V113. Any label should be declared in the same block as 'goto' statement or in any block enclosing it. The function with the 'abort/exit/getenv/system' name should not be used. V1061. How do I stop the Flickering on Mode 13h? Was Aristarchus the first to propose heliocentrism? Priority of '+' operation is higher than priority of '<<' operation. The 'foo' word is suspicious. Using 'await' in a critical section may lead to a lock being released on a different thread. Size of an array is not specified. Expression inside assert statement can change object's state. V3119. Microsoft-specific: In the Microsoft C implementation, the long long type is large enough to hold the product of two int values without overflow. V2604. V2583. V1074. Argument is of the 'T' type. V772. V535. V2607. V659. Casting potential 'null' value to a value type can lead to NullReferenceException. Uppercase (lowercase) string is compared with a different lowercase (uppercase) string. V3030. Do not use old versions of SSL/TLS protocols as it may cause security issues. V6070. V676. V633. MISRA. The 'a' variable was used after it was assigned through null-conditional operator. V3047. The return value of the function should probably be compared with std::string::npos. Why Oracle let function (basic/nopipelined) without RETURN compile, and throws error in execution. Code's operational logic does not correspond with its formatting. OWASP. The 'swap' function may interchange a variable with itself. Recurring check. In such a case, the comparison operation can potentially behave unexpectedly. MISRA. V6074. Possible log injection. Is that what you want? The 'GetObjectData' implementation in unsealed type is not virtual, incorrect serialization of derived type is possible. Absolute values of both operands are equal. V3524. V3036. V6038. V2588. Awaiting on expression with potential null value can lead to throwing of 'NullReferenceException'. A function with a non-void return type must return an answer no matter what its parameters are. V105. Tag names should be unique across all name spaces. Conversion between pointers of different object types should not be performed. External identifiers should be distinct. Implicit type conversion from enum type to integer type. V1017. A memory/resource leak is possible. V6084. V2612. An identifier declared in an inner scope should not hide an identifier in an outer scope. Constructor contains potentially uninitialized members. Thread.sleep() inside synchronized block/method may cause decreased performance. Consider inspecting the NNth argument of the 'Foo' function. nlohmann/json.hpp:20017:5: warning: non-void function does not return a value in all control paths [-Wreturn-type], reference operator[](T* key) The assignment to a member of the readonly field will have no effect when the field is of a value type. V2535. V549. Consider checking the first actual argument of the 'Foo' function. The variable is assigned the same value on several loop iterations. Consider inspecting this expression. control reaches end of non-void functions -wreturn-type. V3187. V201. V6031. V2613. V2537. V539. Consider adding the 'cin.fail()' function call to the conditional expression. Odd semicolon ';' after 'if/for/while' operator. Consider replacing methods: 'insert' -> 'emplace', 'push_*' -> 'emplace_*'. Controlling expressions should not be invariant. Unlike this recommendation, that rule is restricted to functions from the Standard C library. V3061. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. Automatic unboxing of a variable may cause NullPointerException. It is possible that different variables are used inside initializer and iterator. Sign in to comment Potentially tainted data might be used to execute a malicious script. use custom JSON_THROW_USER without exceptions. Array is used as pointer to single object. Part of conditional expression is always true/false. V5615. Let's consider an example. This pattern is suspicious. V792. V764. The analyzer will not issue a warning for the following code fragment: There will also be no undefined behavior if, during the function execution, another function that does not return control, is called. V646. Call of the 'Foo' function will lead to buffer overflow. If total energies differ across different software, how do I decide which software to use? V518. 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. A component of TimeSpan is used, which does not represent full time interval. Use a plain return statement to make your intent clear. Semicolon ';' is probably missing after the 'return' keyword. The 'continue' operator will terminate 'do { } while (false)' loop because the condition is always false. Both operands of the '??' V801. What should I follow, if two altimeters show different altitudes? Potentially unsafe double-checked locking. V123. The memory areas must not overlap. V714. Suspicious type cast: 'Type1' to ' Type2'. V6039. The 'HasFlag' method always returns 'true' because the value '0' is passed as its argument. Use of outdated cryptographic algorithm is not recommended. V122. Consider inspecting the expression. Exception classes should be publicly accessible. V749. Expression of the 'A =- B' kind is used.