MISRA. Check for typos. Absolute value of the left operand is less than the right operand. Referenced package contains vulnerability. Here's the correct version: The 'main' and 'wmain' functions are the exceptions. Incorrect shifting expression. V548. V3133. 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. Why Oracle let function (basic/nopipelined) without RETURN compile, and throws error in execution. Why did US v. Assange skip the court of appeal? Exception was thrown by pointer. The function with the 'abort/exit/getenv/system' name should not be used. Size of the 'time_t' type is not 64 bits. MISRA. V3163. V586. V3134. V3125. Expression used in condition should have essential Boolean type. V525. MISRA. If no return expression is supplied, the Microsoft C runtime returns a value that indicates success (0) or failure (a non-zero value). MISRA. Use of two opposite conditions. This return value is also printed. It is possible that an error is present. Is it safe to publish research papers in cooperation with Russian academics? V111. Pointer is cast to a more strictly aligned pointer type. The 'memset/memcpy' function is used to nullify/copy fields of 'Foo' class. Expression resulting from the macro expansion should be surrounded by parentheses. Consider inspecting the expression. V768. V604. The object was used after it was verified against null. int sometimes ( int x) { if (x > 0) { return 2*x; } } V3139. It is suspicious that the value 'X' of HRESULT type is compared with 'Y'. Probably meant: (T1)((T2)a + b). Find centralized, trusted content and collaborate around the technologies you use most. Iterators for the container, used in the range-based for loop, become invalid upon a function call. V1038. V6085. Unable to start the analysis on this file. V584. The statement std::cout << "B" is never executed because the function has returned to the caller prior to that point. The analyzer has detected a non-void function with an execution path that does not return a value. V6028. Two opposite conditions were encountered. The predefined identifier '__func__' always contains the string 'operator()' inside function body of the overloaded 'operator()'. A memory/resource leak is possible. Perhaps another variable should be incremented instead. privacy statement. V578. Values of different enum types are compared. V542. Some statements require values to be provided, and others dont. Converting integers or pointers to BOOL can lead to a loss of high-order bits. Exception classes should be publicly accessible. Potential resurrection of 'this' object instance from destructor. This leads to undefined behavior. It is possible that a typo is present inside the expression. Such functions are usually marked '[[noreturn]]'. V3062. V1018. There is no point to declare constant reference to a number. V3117. V552. MISRA. Consider inspecting the expression. V2515. Size of a pointer is divided by another value. The 'continue' operator will terminate 'do { } while (false)' loop because the condition is always false. Recurrent serialization will use cached object state from first serialization. Function receives an odd argument. rev2023.4.21.43403. External object or function should be declared once in one and only one file. Code contains collection of similar blocks. This way, you won't miss messages from our team in the future. The expression, if present, is evaluated and then converted to the type returned by the function. Already have an account? Suspicious comparison found: 'a == b == c'. For more information on hiding warnings or treating warnings as errors, see Configuring Warnings in Visual Basic. The size of the bit mask is less than the size of the first operand. V6033. V3052. The expression contains a suspicious mix of integer and real types. Declaring virtual methods in a class marked as 'final' is pointless. Overflow check is incorrect. V2582. V610. V3171. Check lines: N1, N2. MISRA. The 'cin.eof()' condition is insufficient to break from the loop. Why does Acts not mention the deaths of Peter and Paul? A smart pointer may not destroy an object correctly. V1029. AUTOSAR. It is possible that 'else' block was forgotten or commented out, thus altering the program's operation logics. V3174. What differentiates living as mere roommates from living in a marriage-like relationship? If a function returns no meaningful value, it should be declared with return type void. Function returns a pointer to the internal string buffer of a local object, which will be destroyed. Only values returned from fgetpos() can be used as arguments to fsetpos(). V792. however, it floods the compiler output. V600. V751. The 'malloc' function allocates suspicious amount of memory calculated by 'strlen(expr)'. Here is a full example. V6052. Empirical analysis. Variable was used as a divisor before it was compared to zero. It is possible that 'else' block was forgotten or commented out, thus altering the program's operation logics. No objects are passed to the 'std::scoped_lock' constructor. Suspicious string consisting of two parts is used for initialization. New variable with default value is created instead of 'std::unique_lock' that locks on the mutex. Learn more about Stack Overflow the company, and our products. The standard input/output functions should not be used. It is suspicious that it is used as a variable of a Boolean-type. To learn more, see our tips on writing great answers. V748. Asking for help, clarification, or responding to other answers. MISRA. Unbounded functions performing string operations should not be used. It is not advised to declare type 'T' as 32-bit type. This condition was already verified in previous line. MISRA. Consider inspecting the 'switch' statement. Consider inspecting the 'T foo = foo = x;' expression. V625. For more information, see "Behavior" in Function Statement. Consider inspecting the expression. Allocation of memory by the pattern "(X*)malloc(sizeof(Y))" where the sizes of X and Y types are not equal. The 'foo' word is suspicious. Waiting on this expression is unreliable, as compiler may optimize some of the variables. V1064. Two similar code fragments were found. While, on the other hand, if we try to use/call some function to complete the throw, it is facing the well known error/warning of: no return statement in function returning non-void. The 'throw' keyword could be missing. V3537. AUTOSAR. Cyclomatic complexity: NN. The closing tag was encountered, while the tag was expected. In such a context, we can only call value-returning functions. Use of 'Foo' uninitialized variable. So, the compiler generates an error. V3143. V680. V6071. 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. MISRA. The pointer is cast to an integer type of a larger size. The value from the uninitialized optional is used. Analysis aborted by timeout. Correction-related comments will be deleted after processing to help reduce clutter. The value should be non-negative. V641. V3099. V005. AUTOSAR. V662. V747. V1056. I recently fixed something similar in #2898 which is not yet merged. Suspicious assignment inside the conditional expression of 'if/while/for' statement. V3164. Possible excessive expression or typo. V6017. The best answers are voted up and rise to the top, Not the answer you're looking for? The signature of method 'X' does not conform to serialization requirements. V1084. A part of conditional expression is always true/false if it is evaluated. Some types of expressions require values. This can quickly overflow stack. Integer constant is converted to pointer. Unchecked tainted data is used in expression. The analyzer has detected a non-void function with an execution path that does not return a value. V3545. ps: thanks for the awesome library. The first 'if' statement contains method return. MISRA. This means that the second 'if' statement is senseless. "Not Spam" button for our message. Consider inspecting the condition for mistakes. The virtual destructor is not present, although the 'Foo' class contains virtual functions. Possibly, it was intended to be escaped. What were the poems other than those by Donne in the Melford Hall manuscript? Function with a non-void return type should return a value from all exit paths. MISRA. 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). Functions are not required to return a value back to the caller. In this lesson, well explore functions with a return type of void. operator works in a different way than it was expected. V3521. V537. It is inefficient to identify an empty string by using 'strlen(str) > 0' construct. MISRA. Consider inspecting the expression. Use of uninitialized variable 'Foo'. AUTOSAR. Do not define an unnamed namespace in a header file. V3539. V3098. Identifiers declared in the same scope and name space should be distinct. V3554. V3065. Explicit conversion of pointer type to 32-bit integer type. 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. V3177. V3548. Not all IDisposable members are properly disposed. The 'A' function was called several times with identical arguments. What happens to the returned value, if one is specified, depends on the implementation. It is likely that a wrong variable is being incremented inside the 'for' operator. V6024. Consider using '||' and '&&' instead. V3021. Have a question about this project? Remember that members are initialized in the order of their declarations inside a class. First 'case' operator may be missing. V2016. V5013. Expression is equivalent to moving one unique pointer to another. In this case, we can call either a non-value returning function, or we can call a value-returning function and just ignore the return value. A thread can wait indefinitely or experience a spurious wake-up. V754. The class implements a copy constructor/operator=, but lacks the operator=/copy constructor. InvalidClassException may occur during deserialization. OWASP. Making statements based on opinion; back them up with references or personal experience. Consider inspecting signed and unsigned function arguments. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. It means that there is no default return value for your function outside of the for loop. "Signpost" puzzle from Tatham's collection, QGIS automatic fill of the attribute table by expression, Generating points along line with specifying the origin of point generation in QGIS. V574. The result of the right shift operation will always be 0. V509. V1024. 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) Consider inspecting it for a possible error. For example: In the above program, the value to be printed needs to be provided on the right-side of the std::cout <<. V793. 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. OWASP. The value is assigned to the 'x' variable but is not used. V1073. Argument is of the 'T' type. Is a return statement mandatory for C++ functions that do not return void? V3540. V6081. Conversions between pointers to objects and integer types should not be performed. Inspect the program's logic. Unary minus operator should not be applied to an expression of the unsigned type. V653. OWASP. V6044. A more efficient way is to check: str[0] != '\0'. 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? MISRA. Why does an overridden function in the derived class hide other overloads of the base class? Possible typo in the spelling of a pre-defined macro name. Hi, been using 2.0.1 so far over the proposed workaround (void function instead of non-void function). This may be a potential error. Function call may lead to buffer overflow. Collection is modified while iteration is in progress. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. Loop break conditions do not depend on the number of iterations. V1037. V3514. V302. V6076. Custom declaration of standard type. The opportunity to suppress the warning was overlooked. V2520. V595. V3092. Possible incorrect order of arguments passed to method. V3153. V3101. V665. V677. V1067. V3102. If certain compiler flags are passed, this type of error or warning might get suppressed entirely, which will lead to run-time faults if the given function gets called in the program. Conditional expressions of 'if' statements located next to each other are identical. Consider refactoring 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) nlohmann/json.hpp:20925:5: warning: non-void function does not return a value in all control paths [-Wreturn-type] A Function procedure has at least one possible path through its code that does not return a value. Has the cause of a rocket failure ever been mis-identified, such that another launch failed due to the same problem? MISRA. Flowing off the end of thesefunctions is equivalent to a'return 0;'. Microsoft-specific: In the Microsoft C implementation, the long long type is large enough to hold the product of two int values without overflow. V5609. Operands of the logical '&&' or the '||' operators, the '!' It's possible that an assigned variable should be checked in the next condition. This means that the second 'if' statement is senseless. V5622. A pointer/reference parameter in a function should be declared as pointer/reference to const if the corresponding object was not modified. Comparison with 'double.NaN' is meaningless. V2611. V3129. Consider inspecting the 'for' operator. Destructor of 'Foo' class is not declared as virtual. Undefined behavior will occur in case of signed integer overflow. There should be no user-defined variadic functions. V673. Silent suppression of exceptions can hide errors in source code during testing. V771. There is nothing we can do in this situation - there are no default values to return in case of exceptions. V2603. V714. V684. V1069. V5003. V823. V6059. So far, we never make a pedantic check with exceptions switched off. V553. Pointer is compared with 'zero' value. V6063. But, do are you sure you want your return statement inside your loop to begin with? The name of 'X' field/property in a nested type is ambiguous. V3155. It is possible that a call to 'Start' method is missing. V510. You are assuming that loop will always run, but, what if an empty string ends up getting submitted? Numeric Truncation Error. MISRA. Suspicious return of a local reference variable which always equals null. V1017. Consider inspecting the first parameter of 'getline' function. Function body contains the 'X' label that is not used by any 'goto' statements. (i have tried it with just else instead of else if and get same error). V6006. :' operator uses constants from different enums. Examine the substrings "abc" and "abcd". The second block starts with NN string. Nonsensical comparison: pointer < 0. Consider using the 'Ptr' version of the 'foo' function here. MISRA. V512. A function name may be missing. V104. Does a password policy with a restriction of repeated characters increase security? Update: You need to make your function return a vector in every condition as suggested in comments. Unsafe invocation of event, NullReferenceException is possible. V2545. Although GCC is able to analyze the code and determine that exactly one of the cases is executed (as shown in the supplement below), presumably this analysis occurs only later in the compilation process. The result of an assignment expression should not be used. The first statement in print() prints A. Possible Zip Slip vulnerability. Code formatting implies that the statement should not be a part of the 'then' branch that belongs to the preceding 'if' statement. warning: 'return' with a value, in function returning void 2. V661. Expression contains a suspicious mix of integer and real types. MISRA. The standard signal handling functions should not be used. An item with the same key has already been added. V6074. V2622. If a function sometimes forgets to return a result, you will get a warning (if you have requested warnings). It is more efficient to search for 'X' character rather than a string. Possible ReDoS vulnerability. Violated order of exception handlers. The variable was used to initialize itself. The function located to the right of the '|' and '&' operators will be called regardless of the value of the left operand. V711. V2003. Value of 'char' type is added to a string pointer. OWASP. OWASP. Its representation is implementation-defined. operator should have 'bool' type. V1060. Locking operations must be performed on the same thread. An odd sequence of assignments of this kind: A = B; B = A; V3038. During the initial analysis, the code nominally contains three code paths. The '? Function with a non-void return type should return a value from all exit paths. Possible NoSQL injection. V626. There are two 'if' statements with identical conditional expressions. It's probably an error or un-optimized code. OWASP. V3173. Potentially tainted data is processed by regular expression that contains an unsafe pattern. V6021. A value-returning function should include a return statement, containing an expression. Constant expression in switch statement. V520. V602. If you do this, the last statement before End Function should be a Return statement. The function with the 'atof/atoi/atol/atoll' name should not be used. MISRA. V6103. I did return true and false but its still giving me this error [deleted] 2 yr. ago More posts you may like V589. MISRA. OWASP. Possible server-side request forgery. Use volatile variable(s) or synchronization primitives to avoid this. V832. V1002. This can cause concurrency issues. An identifier declared in an inner scope should not hide an identifier in an outer scope. Perhaps this is a mistake. Consider inspecting the expression. Pointer was used before its check for nullptr. One pair of parentheses is unnecessary or misprint is present. V1028. The resulting value is meaningless and should not be used. density matrix. V2558. V1075. Constructor parameter is not used. An exception handling block does not contain any code. Array indexing should be the only form of pointer arithmetic and it should be applied only to objects defined as an array type. V519. Possibly an incorrect HTML. Probably meant: '\xNN'. operator are identical. V645. The hyperbolic space is a conformally compact Einstein manifold. OWASP. It is recommended to use the 'make_unique/make_shared' function to create smart pointers. Consider inspecting the expression. Probably meant: *ptr = zero. Particularly, if during the function execution an exception is thrown and is not caught in the body of the same function, there will be no undefined behavior. Without re-registering for finalization, destructor will not be called a second time on resurrected object. The result will always be zero. Size of an array is not specified. By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. Does this function have explicit return values on all control paths? V1004. Nonsensical comparison of two different functions' addresses. 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. V706. V5301. A function that does not return a value is called a non-value returning function (or a void function). Different containers are used to set up initial and final values of iterator. AUTOSAR. MISRA. V765. No more than one iteration of the loop will be performed. rev2023.4.21.43403. V612. The '!=' operator should probably be used here. V3046. V1062. Syntax: return[expression]; There are various ways to use return statements. The '? MISRA. AUTOSAR. Field 'A' is being used before it was initialized. V774. V652. Array indexing should be the only form of pointer arithmetic and it should be applied only to objects defined as an array type. V506. The passed line may contain format specification. Function execution could be deferred. Consider inspecting the loop expression. V2550. V828. Expression can be simplified: check similar operands. The variable 'X' is being used for this loop and for the outer loop. V636. AUTOSAR. AUTOSAR. V1078. It is suspicious that a char or string literal is added to a pointer. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. V3123. Review captured variable in lambda expression. Annotation that does not have 'RUNTIME' retention policy will not be accessible through Reflection API. A variable of the memsize type is read from a stream. AUTOSAR. He also rips off an arm to use as a sword. The resulting value could be inaccurate. Void functions don't need a return statement A void function will automatically return to the caller at the end of the function. It causes the function to return to the caller immediately. V581. Decreased performance. Suspicious return of an always empty collection. MISRA. See documentation for details. V3122. 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. V740. Unchecked tainted data is used in expression. An object is used as an argument to its own method. A double memory deallocation will occur. MISRA. Site design / logo 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA. MISRA. Comma may be missing. Suspicious use of BigDecimal class. Initializer of a field marked by [ThreadStatic] attribute will be called once on the first accessing thread. Derived class object was copied to the base class object. Unlike this recommendation, that rule is restricted to functions from the Standard C library. The initial value of the index in the nested loop equals 'i'. V707. Calling overrideable class member from constructor is dangerous. Possible incorrect order of arguments passed to function. V3024. V5608. V634. V5627. V3011. V766. Content Discovery initiative April 13 update: Related questions using a Review our technical responses for the 2023 Developer Survey, C, error: control reaches end of non-void function [-Werror,-Wreturn-type], Control may reach end of non-void function [-Werror,-Wreturn-type]. Suspicious explicit type casting. Use volatile variable(s) or synchronization primitives to avoid this. V663. Suspicious type cast: 'Type1' to ' Type2'. Consider checking the Nth actual argument of the 'Foo' function. A Function procedure has at least one possible path through its code that does not return a value. The object was created but it is not being used. V3108. The passing of data to or from this function may be affected. (This const / volatile distinction is not important.) MISRA. What is scrcpy OTG mode and how does it work? Potentially tainted data is used in the XPath expression. Decreased performance. Consider inspecting the application's logic. V3055. Unsafe double-checked locking. V1013. The expression of 'foo(foo(x))' pattern is excessive or contains an error. Pointer was used in the logical expression before its check for nullptr in the same logical expression. operator should have 'bool' type. Call of the 'Foo' function will lead to buffer overflow. V103. The 'Foo' function receives the pointer and its size as arguments. It is easier to guarantee that every return from the procedure returns a value if you always use the Return statement. V2537. V2589. Both operands of an operator should be of the same type category. Function '' doesn't return a value on all code paths. Consider inspecting the loop expression. Consider inspecting the expression. V539. V3551. Throwing from exception constructor may lead to unexpected behavior. MISRA. Consider inspecting the 'for' operator. The '? Possible overflow. How do I count the number of sentences in C using ". Potential XXE vulnerability. It is possible that different variables are used inside initializer and iterator. Potentially tainted data is used in the URL. Is it safe to publish research papers in cooperation with Russian academics? Passing objects of incompatible types to the method of collection. Continue with Recommended Cookies. The 'A' class contains 'Dispose' method. OWASP. V759. Compiler may delete 'memset' function call that is used to clear 'Foo' buffer. V2585. Function receives suspicious argument. V1085. Probably meant: *ptr != zero. It is possible that a wrong variable is incremented inside the 'for' operator. MISRA. V2592. V815. The 'SysFreeString' function should be called only for objects of the 'BSTR' type. Its priority is lower than priority of other operators in its left part. return expressionopt ; The value of expression, if present, is returned to the calling function. 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. Dangerous widening type conversion from an array of derived-class objects to a base-class pointer. The object is already of the same type. We will email you at. What if I write return statement in constructor? Line whose first token is '#' should be a valid preprocessing directive. Possible overflow. V3550. V2502. OWASP. Constant expression in switch statement.