--- description: "Learn more about: Warning C26457 USE_STD_IGNORE_INSTEAD_OF_VOID_CAST" title: Warning C26457 ms.date: 3/1/2021 f1_keywords: ["C26457", "USE_STD_IGNORE_INSTEAD_OF_VOID_CAST"] helpviewer_keywords: ["C26457"] --- # Warning C26457 > `(void)` should not be used to ignore return values, use '`std::ignore =`' instead (es.48) ## Remarks Excerpt from the [C++ Core Guideline ES.48](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es48-avoid-casts): > Never cast to `(void)` to ignore a `[[nodiscard]]` return value. If you deliberately want to discard such a result, first think hard about whether that is really a good idea (there is usually a good reason the author of the function or of the return type used `[[nodiscard]]` in the first place). If you still think it's appropriate and your code reviewer agrees, use `std::ignore =` to turn off the warning which is simple, portable, and easy to grep. Code analysis name: `USE_STD_IGNORE_INSTEAD_OF_VOID_CAST` ## Example Use `std::ignore` instead of cast to `void`: ```cpp struct S{}; [[nodiscard]] S getS(); void function() { (void) getS(); // C26457 std::ignore = getS(); // OK } ```