warning non void function does not return a value

Conversions should not be performed between pointer to function and any other type. The function with the 'abort/exit/getenv/system' name should not be used. Incorrect format. V3028. Some diagnostic messages may contain incorrect line number. What is the Russian word for the color "teal"? V6042. Loop break conditions do not depend on the number of iterations. Returning a value from a void function is a compile error. MISRA. The DllMain function throws an exception. V6104. Unsigned right shift assignment of negative 'byte' / 'short' value. Executing this query may lead to an error. Adding EV Charger (100A) in secondary panel (100A) fed off main (200A). 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). EOF should not be compared with a value of the 'char' type. Consider inspecting usage of 'Y' counter. V530. Function returns pointer/reference to temporary local object. The 'goto' statement should not be used. It is suspicious that the body of 'Foo_1' function is fully equivalent to the body of 'Foo_2' function. V2517. V695. V2578. V6002. Consider inspecting the expression. Undefined behavior. V2568. 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. MISRA. V1027. V3172. Sign in And if candidate_count is 0 or negative it will return without a value at all (hence the error). The identifier 'main' should not be used for a function other than the global function 'main'. V2582. AUTOSAR. Conditional expression of 'if' statement is incorrect for the HRESULT type value 'Foo'. Function call may lead to buffer overflow. Generating points along line with specifying the origin of point generation in QGIS. malloc() function accepts a dangerous expression in the capacity of an argument. V012. The opportunity to suppress the warning was overlooked. Function should not contain labels not used by any 'goto' statements. The 'Foo' function receives class-type variable as 'N'th actual argument. The second function call to function printHi() wont even compile. Expressions that use comma operator ',' are dangerous. Inspect the Nth argument. V633. Consider a case where the vector is empty. V722. Function exited without releasing the pointer/handle. Currently your code is returning the vector based on conditions. Consider inspecting the 'foo' function. There should be no user-defined variadic functions. V558. No objects are passed to the 'std::scoped_lock' constructor. Potential division by zero. The parentheses around the return expression in square are evaluated as part of the expression, and aren't required by the return statement. NullReferenceException is possible. Array is used as pointer to single object. operator instead. The compiler has been asked to warn when a function has a control path that doesn't return a value (although not mentioned in the message, throwing a value and possibly calling a non-returning function may also be considered acceptable). V5623. Connect and share knowledge within a single location that is structured and easy to search. The 'malloc' function is used to allocate memory for an array of objects that are classes containing constructors/destructors. V3538. Do not use real-type variables as loop counters. Uninitialized variables are used when initializing the 'A' variable. You may or may not use the return . Let's consider an example. MISRA. MISRA. Does this function have explicit return values on all control paths? V652. English version of Russian proverb "The hedgehogs got pricked, cried, but continued to eat the cactus". MISRA. The expression is incorrect or it can be simplified. Non-atomic modification of volatile variable. However, this statement is trying to send the return value of printHi to std::cout to be printed. Two similar code fragments. 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. V502. Dangerous explicit type pointer conversion. Any loop should be terminated with no more than one 'break' or 'goto' statement. MISRA. The switch statement does not cover all values of the enum. V2569. Potentially unsafe double-checked locking. Defining an absolute path to the file or directory is considered a poor style. V1024. The function with the 'qsort/bsearch' name should not be used. MISRA. V784. V533. 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. V118. The 'static' storage class specifier should be used in all declarations of object and functions that have internal linkage. Parameter is not utilized inside method's body. Consider inspecting the expression. Consider replacing standard container with a different one. V111. Dangerous call of 'Foo' function. Potentially infinite loop. V611. It is possible that another argument should be passed instead. Consider using of 'if-else' construct. OWASP. Object was created but not used. Single-bit bit fields should not be declared as signed type. Initializer of a field marked by [ThreadStatic] attribute will be called once on the first accessing thread. V5609. The code's operational logic does not correspond with its formatting. V1023. V3069. Void functions are created and used just like value-returning functions except they do not return a value after the function executes. Object created using 'new' operator is immediately cast to another type. AUTOSAR. MISRA. The name of 'X' field/property in a nested type is ambiguous. The variable is incremented in the loop. The '#pragma warning(push/pop)' should be used instead. Consider inspecting the condition. V3520. Pointer was used before its check for nullptr. V6006. V051. warning: 'return' with a value, in function returning void 2. V3546. Consider using a comparison with defined precision: fabs(A - B) < Epsilon or fabs(A - B) > Epsilon. An identifier declared in an inner scope should not hide an identifier in an outer scope. Suspicious invocation of Thread.run(). V827. V3161. V1039. ** By clicking this button you agree to our, * By clicking this button you agree to our, Free PVS-Studio license for Microsoft MVP specialists, To get the licence for your open-source project, please fill out this form. V3502. Probably meant 'A[B] < C'. OWASP. V3140. Potentially tainted data is processed by regular expression that contains an unsafe pattern. The 'if' 'else if' construct should be terminated with an 'else' statement. Consider refactoring the 'Foo' function. Presence of #line directives may cause some diagnostic messages to have incorrect file name and line number. V6076. V2533. The other reason is that void more clearly conveys that the function is supposed to not return a value, rather than return null specifically. Possible XPath injection. For more information on hiding warnings or treating warnings as errors, see Configuring Warnings in Visual Basic. Unity Engine. Learn more about Stack Overflow the company, and our products. V751. The compiler has been asked to warn when a function has a control path that doesn't return a value (although not mentioned in the message, throwing a value and possibly calling a non-returning function may also be considered acceptable). It is possible that ',' comma is missing at the end of the string. V2543. The escape sequence ends with a letter and the next character is also a letter. V3059. How can I control PNP and NPN transistors together from one pin? V696. V2560. Use of two opposite conditions. V791. ", "!"? Passing objects of incompatible types to the method of collection. OWASP. Argument is a non-constant reference. It is not recommended to return null or throw exceptions from 'toString' / 'clone' methods. V3132. V549. V3056. V010. MISRA. Thus, the warning is a very useful one and you should consider yourself lucky that the compiler noticed the bug. Can you still use Commanders Strike if the only attack available to forego is an attack against an ally? V2540. Expressions with enum underlying type should have values corresponding to the enumerators of the enumeration. V735. Result of this expression will be implicitly cast to 'Type'. V6054. V773. Functions' declarations with 'Foo' name differ in 'const' keyword only, while these functions' bodies have different composition. V6065. Use direct analyzer integration or compiler monitoring instead. Odd semicolon ';' after 'if/for/while' operator. Usage of non memsize type for pointer arithmetic. The long long result is stored in squared, then printed. Consider inspecting the expression for function call. V581. It is possible that a backslash should be used instead: '\r'. V3517. Expression inside assert statement can change object's state. Making statements based on opinion; back them up with references or personal experience. V3176. Potential division by zero. V2566. Calling the 'SingleOrDefault' method may lead to 'InvalidOperationException'. Literal suffixes should not contain lowercase characters. V123. V796. V645. V831. If total energies differ across different software, how do I decide which software to use? The value of an expression is a potentially destroyed Unity object or null. Code's operational logic does not correspond with its formatting. MISRA. Deprecated CLR switch was detected. Serialization order of fields should be preserved during deserialization. V3011. Use filter buttons or 'Don't Check Files' settings to enable message display. The field will have default value on different threads. Variables are initialized through the call to the same function. This variable is passed by reference to the 'Foo' function in which its value will be used. One pair of parentheses is unnecessary or misprint is present. It is suspicious and can possibly be an error. MISRA. V3121. Loop break conditions do not depend on the number of iterations. An identifier with array type passed as a function argument should not decay to a pointer. V6081. V670. AUTOSAR. Bit fields should only be declared with explicitly signed or unsigned integer type. V674. Violated order of exception handlers. Memory allocation and deallocation methods are incompatible. The predefined identifier '__func__' always contains the string 'operator()' inside function body of the overloaded 'operator()'. V794. Probably the '-=' should be used here. Size of an array is not specified. Is it safe to publish research papers in cooperation with Russian academics? The 'ThreadStatic' attribute is applied to a non-static 'A' field and will be ignored. V3068. V1019. V6028. V3057. Unsafe invocation of event, NullReferenceException is possible. The resulting value is meaningless and should not be used. V1021. is there a trick to keep in mind when adding your own JSON_THROW? The argument was passed to method several times. MISRA. V102. V2615. - Nate Eldredge. This file is marked with copyleft license, which requires you to open the derived source code. Postfix increment/decrement is senseless because this variable is overwritten. . : .'. Parameter of 'std::stop_token' type is not used inside function's body. Upper bound of case range is less than its lower bound. V732. Variable length array types are not allowed. V3516. Bounds should not contain size of a buffer, but a number of characters it can hold. It's probably an error or un-optimized code. The value of uninitialized variable should not be used. Potentially tainted data is used in the XPath expression. V3528. MISRA. Understanding the probability of measurement w.r.t. V517. Expression's value is copied at the variable declaration. But, do are you sure you want your return statement inside your loop to begin with? Only the first member of enumerator list should be explicitly initialized, unless all members are explicitly initialized. MISRA. Expression is equivalent to moving one unique pointer to another. V3019. Inspect the program's logic. V521. String literal should not be assigned to object unless it has type of pointer to const-qualified char. Consider inspecting the expression. V826. V3141. V1078. A return statement ends the execution of a function, and returns control to the calling function. V2571. V2004. V582. Variable is used after it is moved. There should be no implicit integral-floating conversion. V103. OWASP. How to Make a Black glass pass light through it? V766. Replacing a 32-bit loop counter with 64-bit introduces crazy performance deviations with _mm_popcnt_u64 on Intel CPUs. V5602. V3518. Line splice results in a character sequence that matches the syntax of a universal-character-name. Unbounded functions performing string operations should not be used. Consequently, the function needs to have a statement that returns the object of the corresponding type. V1097. Unary minus operator should not be applied to an expression of the unsigned type. If you haven't received our response, please do the following: check your Spam/Junk folder and click the The argument's value is greater than the size of the collection. Use volatile variable(s) or synchronization primitives to avoid this. The functions from time.h/ctime should not be used. By default, this message is a warning. V807. A more efficient way is to check: str[0] != '\0'. V2524. privacy statement. V6098. It is possible that '1' should be present instead of '0'. V006. Variable is not passed into foreach loop by reference, but its value is changed inside of the loop. V2014. V598. Consider using '||' and '&&' instead. 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 : Perhaps, it is a typo and 'X' variable should be used instead of 'Y'. In such a case, the comparison operation may behave unexpectedly. OWASP. Every 'switch' statement should contain non-empty switch-clauses. The 'operator &&', 'operator ||', 'operator ,' and the unary 'operator &' should not be overloaded. The method does not override another method from the base class. The memory areas must not overlap. Double negation is present in the expression: !!x. Assign the value to the Function procedure name and then perform an Exit Function statement. The 'sizeof' expression returns the size of the container type, not the number of elements. It is suspicious that the value 'X' of HRESULT type is compared with 'Y'. Consider inspecting the expression. If a return value isn't required, declare the function to have void return type. (Experienced programmers will generally use a solitary. V3182. If the function has a void return type, this behavior is okay, but may be considered poor style. V6021. What differentiates living as mere roommates from living in a marriage-like relationship? Consider assigning event to a local variable before invoking it. Consider inspecting the 'for' operator. Odd semicolon ';' after 'if/for/while' operator. V3183. V5601. In a main function, the return statement and expression are optional. V205. The object was created but it is not being used. V5607. Suspicious function declaration. V3089. :' operator uses constants from different enums. AUTOSAR. Two or more case-branches perform the same actions. V641. Array indexing should be the only form of pointer arithmetic and it should be applied only to objects defined as an array type. V3073. V785. In this case, we have the 'main' function. Unexpected function overloading behavior. V1092. V3511. What if I write return statement in constructor? V3078. Recurring check. The expression is incorrect or it can be simplified. If you have parameters instead of "void" in your function's parentheses you have to return something. 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. 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. MISRA. V6044. AUTOSAR. MISRA. MISRA. The 'throw' keyword could be missing. A function should not call itself either directly or indirectly. Flexible array members should not be declared. V3081. Suspicious type cast: 'Type1' to ' Type2'. V3075. The global namespace should only contain 'main', namespace declarations and 'extern "C"' declarations. V3509. Consider utilizing an explicit type cast to avoid the loss of a fractional part. Property setter / event accessor does not utilize its 'value' parameter. :' operator, regardless of its conditional expression, always returns the same value. Number of elements in the allocated array equals the size of a pointer in bytes. String literal contains potential interpolated expression. 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. V6077. Use 'double.IsNaN()' method instead. V3063. 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. V3026. Initial and final values of the iterator are the same. Consider checking for typos. Consider creating a pointer/reference to avoid using the same expression repeatedly. Macro expression is dangerous or suspicious. V532. Lifetime of the heap-allocated variable is limited to the current function's scope. V3539. Constructor parameter is not used. V5614. The '? Function '' doesn't return a value on all code paths. V683. V3144. Decreased performance. Bool type value is compared with value of N. Consider inspecting the expression. Suspicious return of a local reference variable which always equals null. The comma operator should not be used. This way, you won't miss messages from our team in the future. Variables are initialized through the call to the same function. The identifier 'main' should not be used for a function other than the global function 'main'. V3042. Review captured variable in lambda expression. Cast should not convert a pointer to a function to any other pointer type, including a pointer to function type. V2602. Parameter is not used inside method's body. The 'SysFreeString' function should be called only for objects of the 'BSTR' type. Thus, these functionsdo not result inundefined behavior. V648. V2601. MISRA. OWASP. Implicit type conversion of return value to memsize type. So, the solution is to apply the warn_unused_result attribute on the function. V2503. Empirical analysis. V6026. Signed value is converted to an unsigned one with subsequent expansion to a larger type in ternary operator. V2616. V780. V5605. If no value is provided, the compiler will produce a syntax error. It is suspicious that the result of the statement is a part of the condition. By cv void, it simply means a function with void return type, that may be const or volatile. An exception should be caught by reference rather than by value. Suspicious sequence of types castings: pointer -> memsize -> 32-bit integer. Extracting arguments from a list of function calls. This may lead to undefined behavior. check your Spam/Junk folder and click the "Not Spam" button for our message. Consider synchronizing the field on all usages. V121. Declaration should contain no more than two levels of pointer nesting. This is unexpected behavior. Potential logical error. MISRA. V3053. V3160. Buffer size is not a multiple of element size. MISRA. Possibly an incorrect HTML. On 32-bit/64-bit platform, structure size can be reduced from N to K bytes by rearranging the fields according to their sizes in decreasing order. Function receives an odd argument. It is possible that a wrong variable is incremented inside the 'for' operator. V1096. Not all IDisposable members are properly disposed. MISRA. The analyzer is unable to determine the position where this argument is modified. MISRA. The first 'if' statement contains method return. V802. The values used in expressions should have appropriate essential types. The closing tag was encountered, while the tag was expected. V627. The report_ratio function has a void return type, so it doesn't need to explicitly return a value. MISRA. Pointer to local variable 'X' is stored outside the scope of this variable. Consider inspecting the application's logic. Possible overflow. This leads to undefined behavior. The return value of non-void function should be used. V781. OWASP. V2563. V6055. The result of '&' operator is always '0'. Passing the value into the 'Foo' method will result in an exception. The variable 'X' is being used for this loop and for the outer loop. Declaration should contain no more than two levels of pointer nesting. As we know pipelined function doesn't require Return, because of its working and for best programming practice we write it. The '<' operator should probably be replaced with '<<'. So if you want error for specific warning, say -Wreturn-type, just type return-type without -W part as: $ g++ -Werror=return-type source.cpp In general you should always use -Wall option which includes most common warnings this includes missing return statement also. V3126. Pointer was used after the memory was released. V1095. V678. V105. AUTOSAR. V775. V519. Asking for help, clarification, or responding to other answers. The return expression is forced to use a floating-point operation by casting one of the operands to double. Giving short names to global variables is considered to be bad practice. Expression containing increment (++) or decrement (--) should not have other side effects. Analysis of 'Makefile/Utility' type projects is not supported in this tool. Since the function doesnt return a value, this is fine. V6050. To use free version of PVS-Studio, source code files are required to start with a special comment. The switch statement does not cover all values of the enum. Void functions dont need a return statement. V5617. The double result is stored in fraction, then printed. Variable is not used after memory is allocated for it. Consider reviewing the source code that uses the container. Suspicious sequence of assignments: A = B; B = A;. Can the game be left in an invalid state if all state-based actions are replaced? V6022. MISRA. Be advised that the size of the type 'long' varies between LLP64/LP64 data models. V779. The 'switch' statement should have 'default' as the last label. V825. rev2023.4.21.43403. Email? Implicit type conversion from enum type to integer type. V770. V578. V2015. V1025. V303. A compatible declaration should be visible when an object or function with external linkage is defined. V3148. Consider refactoring the code. Consider checking for misprints. If you do this, the last statement before End Function should be a Return statement. V3086. V3048. The 'foo' include guard is already defined in the 'bar1.h' header. V725. V797. Consider replacing this function with 'std::uncaught_exceptions'. Possible incorrect order of arguments passed to method. V726. V3055. Functions are not required to return a value back to the caller. V2614. V708. Identifiers that start with '__' or '_[A-Z]' are reserved. Three potential reasons for issue the warning (elevated to an error) in spite of this come to mind: Due to the way the compiler is constructed, warnings are generally reported early, and suppressing this warning based on later analysis would be difficult. Consider inspecting the expression. V6080. Use a plain return statement to make your intent clear. V2008. V1067. V2574. It's possible that the line was commented out improperly, thus altering the program's operation logics. V3555. Possible typo inside the string literal. V2588. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. V5304. The variable is assigned but is not used by the end of the function. The 'if (ptr != NULL)' check can be removed. When we call a function in a context that requires a value (e.g. V822. Probably meant: *ptr != zero. V588. V742. Consider replacing the call to the 'at()' method with the 'operator[]'. An abnormality within similar comparisons. V602. OWASP. The object is already of the same type. Casts between a pointer to an incomplete type and any other type shouldn't be performed. No return statement is required. MISRA. Iterators are passed as arguments to 'Foo' function. [Serializable] attribute is missing. The '!=' operator should probably be used here. Allocation of memory by the pattern "(X*)malloc(sizeof(Y))" where the sizes of X and Y types are not equal. AUTOSAR. Functions should be declared in prototype form with named parameters. V662. Suspicious code formatting. MISRA. Casting expression to 'X' type before implicitly casting it to other type may be excessive or incorrect. 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. TYPE X[][] is not equivalent to TYPE **X. V3077. V3187. Possible NullReferenceException. V808. It is possible that an assigned variable should be checked in the next condition. It is possible that the number of elements should be calculated by sizeof(A)/sizeof(A[0]). A new object is created, while a reference to an object is expected. V3120. V3024. V3153. V6051. This means that the second 'if' statement is senseless. Incorrect index type: 'foo[not a memsize-type]'. Is that what you want? V3034. V203. If a function sometimes forgets to return a result, you will get a warning (if you have requested warnings). The 'else' keyword may be missing. Use of '\0xNN' characters. I compiled a small program containing the following function definition. Consider inspecting the loop expression. Usage of a suspicious mutex wrapper. Code formatting implies that the statement should not be a part of the 'then' branch that belongs to the preceding 'if' statement. Expression is enclosed by parentheses twice: ((expression)). V511. MISRA. Here's the correct version: The 'main' and 'wmain' functions are the exceptions. This causes unspecified or undefined behavior. V658. Consider inspecting the function call. V2596. Consider inspecting the return statement. MISRA. MISRA. Why does flowing off the end of a non-void function without returning a value not produce a compiler error? This recommendation encompasses ERR33-C. Detect and handle standard library errors. Comparison with 'double.NaN' is meaningless. If no return expression is supplied, the Microsoft C runtime returns a value that indicates success (0) or failure (a non-zero value). The 'Foo' function is called twice in the specified expression to calculate length of the same string. Explicit conversion from memsize type to 32-bit integer type. The result of '&' operator is '0' because one of the operands is '0'. Use _beginthreadex/_endthreadex functions instead of CreateThread/ExitThread functions. Potentially tainted data is used in the path toextractthe file. Macro name overrides a keyword/reserved name. V3522. AUTOSAR. The object was used after it was verified against null. The variable can be constructed in a lower level scope. A switch-expression should not have Boolean type. A variable of the memsize type is read from a stream. Virtual table pointer will be damaged. V684. C-style explicit type casting is utilized. OWASP. We know it knows for two reasons. Possible meaningless check for null, as memory was allocated using 'new' operator. Literal suffixes should not contain lowercase characters. Checking value for null will always return false when generic type is instantiated with a value type. MISRA. The address of an object with local scope should not be passed out of its scope.

Where Does Rob Ninkovich Live, How Many Hosts On Soul Train, Articles W