Unary minus operator does not modify a bool type value. 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? (i have tried it with just else instead of else if and get same error). MISRA. Insecure XML parser is used to process potentially tainted data. V1026. It will be closed before the method exits. Why don't we use the 7805 for car phone chargers? The expression is excessive or contains a misprint. A 'wchar_t *' type string is incorrectly converted to 'BSTR' type string. Consider reviewing the correctness of 'X' item's usage. V2545. V625. Cast should not convert pointer to function to any other pointer type. V1094. Two or more case-branches perform the same actions. V538. The '//' and '/*' character sequences should not appear within comments. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide, FWIW, compiling the example code on godbolt.org with, @EricPostpischil but compiler does not know if, Yes, it does know. The global namespace should only contain 'main', namespace declarations and 'extern "C"' declarations. Use of potentially tainted data in configuration may lead to security issues. V3546. Functions should not have unused parameters. V510. V583. V820. V1085. What is the Russian word for the color "teal"? Argument of sizeof() is a macro, which expands to a number. V3001. I can give he a test with 2.0.3-RC1 and lease you perceive The return keyword is used during the end of to function to get the value back. OWASP. Multiple copies of it will be created in all translation units that include this header file. The first 'if' statement contains method return. Comparing objects of incompatible types. V3124. V3506. How to Make a Black glass pass light through it? This can cause concurrency issues. Incorrect index type: 'foo[not a memsize-type]'. The 'switch' statement should have 'default' as the last label. Consider checking the Nth actual argument of the 'Foo' function. 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. V5623. It is more effective to use the prefix form of ++it. Do not use old versions of SSL/TLS protocols as it may cause security issues. V806. V633. Some types of expressions require values. V2014. Inappropriate attempt to append a null character to a string. Its priority is lower than priority of other operators in its left part. Literal suffixes should not contain lowercase characters. V007. Consider using a comparison with defined precision: fabs(A - B) < Epsilon or fabs(A - B) > Epsilon. The comma operator should not be used. Then, enable it by default, but also make it be enabled by Wpedantic and Wreturn-type. V1052. 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. Potentially tainted data might be used to execute a malicious script. V816. V2617. V3111. Consequently, the function needs to have a statement that returns the object of the corresponding type. Consider using 'i + 1' instead. Decreased performance. Solve "control reaches end of non-void function" Error Consider replacing the expression 'AA' with 'BB'. V6104. int sometimes ( int x) { if (x > 0) { return 2*x; } } EOF should not be compared with a value of the 'char' type. The comma operator should not be used. The 'zero' value is assigned to pointer. warning: non-void function does not return a value Naimur Rahman 44 subscribers Subscribe 1 Share 316 views 6 months ago warning: non-void function does not return a value Show more Show more. Is it safe to publish research papers in cooperation with Russian academics? Consider using '||' and '&&' instead. V681. Absolute value of the left operand is less than the right operand. V693. This causes implementation-defined behavior. Function receives suspicious argument. V540. Usage of potentially invalid handle. Consider inspecting the expression. Condition of a loop is always true/false. V605. It calls strlen once and either jumps to .L1 or falls through to the then code, which rejoins at .L1. Consider synchronizing the field on all usages. MISRA. Identical expression to the left and to the right of compound assignment. V2001. Deprecated CLR switch was detected. V727. Attempt to free memory containing the 'int A[10]' array by using the 'free(A)' function. Consider making the project fully compilable and building it before analysis. V3164. Non-void functions always have to have a return statement. V697. Some warnings could have been disabled. V3511. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. Cannot determine active configuration for project. Waiting on condition variable without predicate. Such absolute value can't be represented in two's complement. Non-void function must return value. V3021. V3548. Error on missing return statement under GCC. MISRA. V010. V6095. V587. It's probably an error or un-optimized code. V3040. Correction-related comments will be deleted after processing to help reduce clutter. Does the 500-table limit still apply to the latest version of Cassandra? Sign in to comment Since the function doesnt return a value, this is fine. WPF: A class containing registered property does not correspond with a type that is passed as the ownerType.type. V2507. V738. The VARIANT_BOOL type is used incorrectly. In such a case, the comparison operation may behave unexpectedly. V546. Pseudo random sequence is the same at every program run. V664. The 'a' variable was used after it was assigned through null-conditional operator. The expression is excessive or contains a logical error. V2537. As your code stands, if candidate_count is greater than 0 the loop will iterate once and then unconditionally return false, which I don't think is what you want. The other function parameter expects a file path instead. Consider inspecting the 'for' operator. Loop break conditions do not depend on the number of iterations. V755. V539. Consider inspecting usage of 'Y' counter. Consider inspecting the expression. V647. The hyperbolic space is a conformally compact Einstein manifold. Perhaps this is a mistake. It is possible that a wrong variable is compared inside the 'for' operator. An excessive check can be simplified. An exception should be caught by reference rather than by value. V560. Suspicious division. The value of an expression is a potentially destroyed Unity object or null. Compiler may optimize out this loop or make it infinite. Uninitialized class member is used when initializing the base class. One of the operands in the operation equals NN. Consider a case where the vector is empty. V3139. Consider checking the N format items of the 'Foo' function. The expression of strlen(MyStr.c_str()) kind can be rewritten as MyStr.length(). Nonsensical comparison of two different functions' addresses. V1096. Explicit conversion from 'float/double' type to unsigned integer type. V2598. Possible incorrect order of arguments passed to method. V744. Object was created but is not used. MISRA. "Not Spam" button for our message. Possibly, it was intended to be escaped. V1006. V3186. Consider verifying the compatibility of 32 and 64 bit versions of the application in the context of a stored data. Try to avoid many return statements in your code. Consider inspecting the expression. Possible SQL injection. Casting expression to 'X' type before implicitly casting it to other type may be excessive or incorrect. V1055. Casts between a pointer to an incomplete type and any other type shouldn't be performed. V826. No objects are passed to the 'std::scoped_lock' constructor. V301. V6047. V3180. V101. Infinite loop is possible. V549. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. V3035. MISRA. Implicit type conversion from enum type to integer type. Function returns pointer/reference to temporary local object. V3066. MISRA. V2560. The standard signal handling functions should not be used. V2616. MISRA. No more than one iteration of the loop will be performed. The 'alloca' function is used inside the loop. V585. MISRA. It is more efficient to search for 'X' character rather than a string. AUTOSAR. Function should not be declared implicitly. This program prints the letters A and B on separate lines. V6085. The report_ratio function has a void return type, so it doesn't need to explicitly return a value. Pointer is cast to a more strictly aligned pointer type. Suspicious return of an always empty collection. AUTOSAR. V6034. V3030. The result will always be zero. Any loop should be terminated with no more than one 'break' or 'goto' statement. Incorrect format. Unreachable code detected. V2599. Check lines: N1, N2. V6059. The 'throw' keyword could be missing. MISRA. V2513. Use filter buttons or 'Don't Check Files' settings to enable message display. Recurring check. MISRA. AUTOSAR. Check your control flow logic and make sure you assign a value before every statement that causes a return. An unconditional 'break/continue/return/goto' within a loop. V2584. The value should be non-negative. Functions should not have unused parameters. The 'else' keyword may be missing. Consider inspecting the loop expression. The variable of char type is compared with pointer to string. 1. V2603. The report_square function calls square with a parameter value of INT_MAX, the largest signed integer value that fits in an int. Connect and share knowledge within a single location that is structured and easy to search. Check lines: N1, N2. Thus, the analyzer will not issue a warning for the following code fragment: You can look at examples of errors detected by the V591 diagnostic. Content Discovery initiative April 13 update: Related questions using a Review our technical responses for the 2023 Developer Survey, Non-void function does not return a value. V1043. The compiler isn't going to go to very much trouble to detect this situation, because functions like throw_blah which are guaranteed to never return are rare, and because except in the simplest of situations, there's no way for it to reliably do so. V2510. The function with the 'abort/exit/getenv/system' name should not be used. Unsafe invocation of event, NullReferenceException is possible. A function that does not return a value is called a non-value returning function (or a void function). Consider inspecting the 'for' operator. V5013. Variable is declared as auto in C. Its default type is int. Locking operations must be performed on the same thread. It is possible that this 'else' branch must apply to the previous 'if' statement. Undefined behavior will occur in case of signed integer overflow. V685. V632. Possible typo inside the string literal. MISRA. MISRA. AUTOSAR. V6030. MISRA. V6038. V3133. Possible missing parentheses. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. The sizeof() operator returns pointer size instead of array size. Literal suffixes should not contain lowercase characters. V3159. V2607. Octal and hexadecimal escape sequences should be terminated. Possible error in program's logic. Logical literal belongs to second operator with a higher priority. It can possibly be replaced by the call to the 'find' function. See documentation for details. Is a return statement mandatory for C++ functions that do not return void? V6045. V3043. V2561. Compound assignment expression 'X += X + N' is suspicious. Consider using: static_cast/const_cast/reinterpret_cast. The consent submitted will only be used for data processing originating from this website. V1086. V2520. V2588. V3144. Priority of '&&' operation is higher than priority of '||' operation. MISRA. V1013. The first call to printHi() is called in a context that does not require a value. Do not warn if a caller of a function marked with attribute warn_unused_result (see Variable Attributes) does not use its return value. Suspicious sequence of types castings: memsize -> 32-bit integer -> memsize. If you would like to change your settings or withdraw consent at any time, the link to do so is in our privacy policy accessible from our home page.. A memory leak will occur in case of an exception. Suspicious function declaration. MISRA. The object was created but it is not being used. V5616. Object slicing. V2580. V3189. The first statement in print() prints A. V3048. nlohmann/json.hpp:20877:5: warning: non-void function does not return a value in all control paths [-Wreturn-type]. "non-void function does not return a value in all control paths". A 32-bit variable is utilized as a reference to a pointer. V2571. It is dangerous to create a local variable within a loop with a same name as a variable controlling this loop. MISRA. The 'malloc' function allocates suspicious amount of memory calculated by 'strlen(expr)'. V2534. V779. Two similar code fragments. V2009. The macro with the 'setjmp' name and the function with the 'longjmp' name should not be used. It is possible that ',' comma is missing at the end of the string. BSTR string becomes invalid. Function body contains the 'X' label that is not used by any 'goto' statements. 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] The '&=' or '|=' operator is redundant because the right operand is always true/false. V2539. V1087. Likewise, report_ratio returns void, so we don't save its return value, either. To subscribe to this RSS feed, copy and paste this URL into your RSS reader. When you include the return (0) statement, you are saying that the function returns a value of 0. V735. V596. MISRA. V530. Function '' doesn't return a value on all code paths. He also rips off an arm to use as a sword. V573. warning: 'return' with a value, in function returning void 2. "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. Browse other questions tagged, Start here for a quick overview of the site, Detailed answers to any questions you might have, Discuss the workings and policies of this site. Presence of #line directives may cause some diagnostic messages to have incorrect file name and line number. Consider assigning realloc() to a temporary pointer. Please check projects and solution configurations. Implicit assignment type conversion to memsize type. V504. The double result is stored in fraction, then printed. V2503. The size of the bit mask is less than the size of the first operand. Maximum size of a vector is known at compile time. Floating-point values should not be tested for equality or inequality. The address of an object with local scope should not be passed out of its scope. The predefined identifier '__func__' always contains the string 'operator()' inside function body of the overloaded 'operator()'. MISRA. An example of data being processed may be a unique identifier stored in a cookie. MISRA. Already have an account? V2613. V796. Consider inspecting usage of 'Y' counter. V751. Consider inspecting the expression. The resource was acquired using 'X' function but was released using incompatible 'Y' function. The function with the 'qsort/bsearch' name should not be used. It is possible that 'else' block was forgotten or commented out, thus altering the program's operation logics. Don't use terminating functions in library code. So it does not know if the second strlen will return the same value as the first one. MISRA. V772. The expression is incorrect or it can be simplified. A Function procedure has at least one possible path through its code that does not return a value. :' operator, regardless of its conditional expression, always returns the same value. The 'switch' statement should have 'default' as the last label. Only values returned from fgetpos() can be used as arguments to fsetpos(). V513. Parameter is not used inside method's body. Decreased performance. V2544. Consider using 'i + 1' instead. V3517. V786. V111. V1069. Be advised that the size of the type 'long' varies between LLP64/LP64 data models. Array is used as pointer to single object. Consider replacing the call to the 'at()' method with the 'operator[]'. Odd semicolon ';' after 'if/for/while' operator. Decreased performance. Explicit type conversion from memsize to double type or vice versa. Consider inspecting the expression. Uninitialized variables are used when initializing the 'A' variable. V2597. V2018. Exceptions raised inside noexcept functions must be wrapped in a try..catch block. Pointer to local variable 'X' is stored outside the scope of this variable. Use volatile variable(s) or synchronization primitives to avoid this. Asking for help, clarification, or responding to other answers. V3054. V730. It is possible that '1' should be present instead of '0'. Thanks for helping to make the site better for everyone. The left operand of integer division is less than the right one. Consider implementing event accessors explicitly or use 'sealed' keyword. Without re-registering for finalization, destructor will not be called a second time on resurrected object. MISRA. 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. V638. OWASP. V6019. V3153. Consider inspecting signed and unsigned function arguments. It can result in an overflow. V3010. Two or more case-branches perform the same actions. V5621. This return value is also printed. Consider inspecting the NN argument of the 'Foo' function. V1029. Function should not contain labels not used by any 'goto' statements. It may happen that flow is never reaching that part of the code but it is important to write for the compiler. When we call a function by itself (e.g. Unhandled exceptions in destructor lead to termination of runtime. How to enter the PVS-Studio license and what's the next move, Release history for previous versions (before 7.00), Getting acquainted with the PVS-Studio static code analyzer on Windows, Build-system independent analysis (C and C++), Direct integration of the analyzer into build automation systems (C and C++), PVS-Studio C# installation on Linux and macOS, How to run PVS-Studio C# on Linux and macOS, Installing and updating PVS-Studio C++ on Linux, Installing and updating PVS-Studio C++ on macOS, How to run PVS-Studio C++ on Linux and macOS, Get started with PVS-Studio in Visual Studio, Using PVS-Studio with JetBrains Rider and CLion, Analyzing Visual Studio / MSBuild / .NET projects from the command line using PVS-Studio, Cross-platform analysis of C and C++ projects in PVS-Studio, How to use the OWASP diagnostic group in PVS-Studio, Analysis of C++ projects based on JSON Compilation Database, How to integrate PVS-Studio into CMake with a CMake module, How to analyze Unity projects with PVS-Studio, Integration of PVS-Studio analysis results into SonarQube, Speeding up the analysis of C and C++ code through distributed build systems (Incredibuild), How to display the analyzer's most interesting warnings, Baselining analysis results (suppressing warnings for existing code), Handling the diagnostic messages list in Visual Studio, How to view and convert analyzer's results, Viewing analysis results with C and C++ Compiler Monitoring UI, Notifying the developer teams (blame-notifier utility), Viewing reports in a SARIF format in Visual Studio Code, Filtering and handling the analyzer output through diagnostic configuration files (.pvsconfig), Excluding files and directories from analysis, Using the PVS-Studio extension for Visual Studio Code, How to use the PVS-Studio extension for Qt Creator, Analysis configuration file (Settings.xml). V3134. Consider inspecting the expression. V1019. V3044. Member invocation on this value may lead to an exception. V520. Possible incorrect order of arguments passed to method. Insecure XML parser is used to process potentially tainted data. Property accessors use different backing fields. The 'SysFreeString' function should be called only for objects of the 'BSTR' type. V709. It is possible that an assigned variable should be checked in the next condition. Unary minus operator should not be applied to an expression of the unsigned type. The 'X' variable was not initialized. Automatic unboxing of a variable may cause NullPointerException. Potentially negative value is used as the size of an array. V3053. Function call may lead to buffer overflow. If no return expression is supplied, the Microsoft C runtime returns a value that indicates success (0) or failure (a non-zero value). The resulting value may be inaccurate. Intermodular analysis may be incomplete, as it is not run on all source files. Examine the substrings "abc" and "abcd". Variable was used as a divisor before it was compared to zero. V830. The 'if' 'else if' construct should be terminated with an 'else' statement. The value is assigned to the 'x' variable but is not used. Lifetime of the heap-allocated variable is limited to the current function's scope. Consider inspecting the condition for mistakes. Conditional escape sequence in literal. Possible dereference of invalid iterator 'X'. The method does not override another method from the base class. Lifetime of the lambda is greater than lifetime of the local variable captured by reference. V770. OWASP. Consider checking the first actual argument of the 'Foo' method. (This const / volatile distinction is not important.) The variable in the loop exit condition does not change its value between iterations. V3521. Consider checking the N format items of the 'Foo' function. Decreased performance. A double memory deallocation will occur. Pointer to FILE should not be dereferenced. MISRA. V6049. V1017. V737. OWASP. V3145. Do not concatenate string literals with different prefixes. V1053. Stack of original exception could be lost. V649. V6063. Possible incorrect order of arguments passed to function. V5601. V2504. V1001. Some of our partners may process your data as a part of their legitimate business interest without asking for consent. Unsafe synchronization on an object. MISRA. 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. It's probably an error or un-optimized code. V6048. V3516. V749. This expression can be simplified. In such a context, we can only call value-returning functions. V220. If a return value isn't required, declare the function to have void return type. 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. V3118. Use _beginthreadex/_endthreadex functions instead of CreateThread/ExitThread functions. When main calls printHi, the code in printHi executes, and Hi is printed. Exception classes should be publicly accessible. V5622. All conditional inclusion preprocessor directives should reside in the same file as the conditional inclusion directive to which they are related. Why do we ask to use Business Consider casting operands, not the result. V805. The 'strlen' function was called multiple times inside the body of a loop. V593. OWASP. V507. V814. The function was annotated as dangerous. g++ How to get warning on ignoring function return value V523. String literal is identical to variable name. V797. He also rips off an arm to use as a sword. V568. Check lines: N1, N2. V762. V1093. More than N bits are required to store the value, but the expression evaluates to the T type which can only hold K bits. AUTOSAR. MISRA. The argument's value is greater than the size of the collection. V711. An empty exception handler. V6014. Array size should be specified explicitly when array declaration uses designated initialization. V6060. [Serializable] attribute is missing. Implicit type conversion N argument of function 'foo' to 32-bit type. Potential logical error. Expressions that use comma operator ',' are dangerous. Calling overrideable class member from constructor is dangerous. The variable from the loop exit condition does not change its value between iterations. MISRA. Converting integers or pointers to BOOL can lead to a loss of high-order bits. caeser - Getting "non-void function does not return a value in all V6012. V612. Backward Incompatible Changes Like the names reserved by the Scalar Type Declarations and Reserve More Types in PHP 7 RFCs, the void return type does not become a reserved word proper, but is instead . Suspicious assignment inside the conditional expression of 'if/while/dowhile' statement. Annotation that does not have 'RUNTIME' retention policy will not be accessible through Reflection API. V1092. V657. V642. V717. Suspicious division. Use 'memmove' function. Consider inspecting the expression. V3017. V584. Conditional expressions of 'if' statements located next to each other are identical. V1077. Consider utilizing an explicit type cast to avoid the loss of a fractional part. 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. The switch statement does not cover all values of the enum. Lowercase 'L' at the end of a long literal can be mistaken for '1'. V613. V790. MISRA. V810. Operand of sizeof() operator should not have other side effects. MISRA. Potentially tainted data is used to create query. Calling method or accessing property of potentially disposed object may result in exception. It is possible that a line was commented out improperly, thus altering the program's operation logic. V2612. V2538. V646. Use of uninitialized variable 'Foo'. Replace iterator++ with ++iterator. Any label should be declared in the same block as 'goto' statement or in any block enclosing it. MISRA. V807. Function '<procedurename>' doesn't return a value on all code paths Consider verifying the initializer. All memory or resources allocated dynamically should be explicitly released. MISRA. :' operator may not work as expected. V3156. Flowing off the end of a non-void function with no 'return' results in undefined behavior. I forgot it would still issue if all paths don't have a return. V1039. V577. An early return is a return statement that occurs before the last line of a function. This variable is passed by reference to the 'Foo' function in which its value will be used. Possible realloc() leak: when realloc() fails to allocate memory, original pointer is lost. The 'foo' local variable has the same name as one of class members. Can you still use Commanders Strike if the only attack available to forego is an attack against an ally? V722. The 'SuspendThread' function is usually used when developing a debugger. V5610. A terminal null is present inside a string. Then main returns a value of 0 (typically used to report success) to end the program. Consider inspecting the expression. Return value of 'Foo' function is required to be used. V653. V2592. First 'case' operator may be missing. It is suspicious that the value 'X' of HRESULT type is compared with 'Y'. Functions should not be declared at block scope. V3501. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide, If you are never going to return something, why do you declare the function as doing so?