1.. title:: clang-tidy - bugprone-unused-return-value 2 3bugprone-unused-return-value 4============================ 5 6Warns on unused function return values. The checked functions can be configured. 7 8Operator overloading with assignment semantics are ignored. 9 10Options 11------- 12 13.. option:: CheckedFunctions 14 15 Semicolon-separated list of functions to check. 16 This parameter supports regexp. The function is checked if the name 17 and scope matches, with any arguments. 18 By default the following functions are checked: 19 ``^::std::async$, ^::std::launder$, ^::std::remove$, ^::std::remove_if$, 20 ^::std::unique$, ^::std::unique_ptr::release$, ^::std::basic_string::empty$, 21 ^::std::vector::empty$, ^::std::back_inserter$, ^::std::distance$, 22 ^::std::find$, ^::std::find_if$, ^::std::inserter$, ^::std::lower_bound$, 23 ^::std::make_pair$, ^::std::map::count$, ^::std::map::find$, 24 ^::std::map::lower_bound$, ^::std::multimap::equal_range$, 25 ^::std::multimap::upper_bound$, ^::std::set::count$, ^::std::set::find$, 26 ^::std::setfill$, ^::std::setprecision$, ^::std::setw$, ^::std::upper_bound$, 27 ^::std::vector::at$, ^::bsearch$, ^::ferror$, ^::feof$, ^::isalnum$, 28 ^::isalpha$, ^::isblank$, ^::iscntrl$, ^::isdigit$, ^::isgraph$, ^::islower$, 29 ^::isprint$, ^::ispunct$, ^::isspace$, ^::isupper$, ^::iswalnum$, 30 ^::iswprint$, ^::iswspace$, ^::isxdigit$, ^::memchr$, ^::memcmp$, ^::strcmp$, 31 ^::strcoll$, ^::strncmp$, ^::strpbrk$, ^::strrchr$, ^::strspn$, ^::strstr$, 32 ^::wcscmp$, ^::access$, ^::bind$, ^::connect$, ^::difftime$, ^::dlsym$, 33 ^::fnmatch$, ^::getaddrinfo$, ^::getopt$, ^::htonl$, ^::htons$, 34 ^::iconv_open$, ^::inet_addr$, isascii$, isatty$, ^::mmap$, ^::newlocale$, 35 ^::openat$, ^::pathconf$, ^::pthread_equal$, ^::pthread_getspecific$, 36 ^::pthread_mutex_trylock$, ^::readdir$, ^::readlink$, ^::recvmsg$, 37 ^::regexec$, ^::scandir$, ^::semget$, ^::setjmp$, ^::shm_open$, ^::shmget$, 38 ^::sigismember$, ^::strcasecmp$, ^::strsignal$, ^::ttyname$`` 39 40 - ``std::async()``. Not using the return value makes the call synchronous. 41 - ``std::launder()``. Not using the return value usually means that the 42 function interface was misunderstood by the programmer. Only the returned 43 pointer is "laundered", not the argument. 44 - ``std::remove()``, ``std::remove_if()`` and ``std::unique()``. The returned 45 iterator indicates the boundary between elements to keep and elements to be 46 removed. Not using the return value means that the information about which 47 elements to remove is lost. 48 - ``std::unique_ptr::release()``. Not using the return value can lead to 49 resource leaks if the same pointer isn't stored anywhere else. Often, 50 ignoring the ``release()`` return value indicates that the programmer 51 confused the function with ``reset()``. 52 - ``std::basic_string::empty()`` and ``std::vector::empty()``. Not using the 53 return value often indicates that the programmer confused the function with 54 ``clear()``. 55 56.. option:: CheckedReturnTypes 57 58 Semicolon-separated list of function return types to check. 59 By default the following function return types are checked: 60 `^::std::error_code$`, `^::std::error_condition$`, `^::std::errc$`, 61 `^::std::expected$`, `^::boost::system::error_code$` 62 63.. option:: AllowCastToVoid 64 65 Controls whether casting return values to ``void`` is permitted. Default: `false`. 66 67:doc:`cert-err33-c <../cert/err33-c>` is an alias of this check that checks a 68fixed and large set of standard library functions. 69