Index: test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp =================================================================== --- test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp +++ test/std/algorithms/alg.nonmodifying/alg.search/search_n_pred.pass.cpp @@ -142,7 +142,7 @@ count_equal::count = 0; // Check that we properly convert the size argument to an integral. - (void)std::search_n(Iter(ic), Iter(ic+sc), UserDefinedIntegral(4), 0, count_equal()); + TEST_IGNORE_NODISCARD std::search_n(Iter(ic), Iter(ic+sc), UserDefinedIntegral(4), 0, count_equal()); count_equal::count = 0; } Index: test/std/containers/associative/map/map.access/at.pass.cpp =================================================================== --- test/std/containers/associative/map/map.access/at.pass.cpp +++ test/std/containers/associative/map/map.access/at.pass.cpp @@ -46,7 +46,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)m.at(6); + TEST_IGNORE_NODISCARD m.at(6); assert(false); } catch (std::out_of_range&) @@ -79,7 +79,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)m.at(6); + TEST_IGNORE_NODISCARD m.at(6); assert(false); } catch (std::out_of_range&) @@ -115,7 +115,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)m.at(6); + TEST_IGNORE_NODISCARD m.at(6); assert(false); } catch (std::out_of_range&) @@ -148,7 +148,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)m.at(6); + TEST_IGNORE_NODISCARD m.at(6); assert(false); } catch (std::out_of_range&) Index: test/std/containers/associative/map/map.ops/count1.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/count1.fail.cpp +++ test/std/containers/associative/map/map.ops/count1.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().count(C2Int{5}); + TEST_IGNORE_NODISCARD M().count(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/count2.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/count2.fail.cpp +++ test/std/containers/associative/map/map.ops/count2.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().count(C2Int{5}); + TEST_IGNORE_NODISCARD M().count(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/count3.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/count3.fail.cpp +++ test/std/containers/associative/map/map.ops/count3.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().count(C2Int{5}); + TEST_IGNORE_NODISCARD M().count(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/equal_range1.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/equal_range1.fail.cpp +++ test/std/containers/associative/map/map.ops/equal_range1.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().equal_range(C2Int{5}); + TEST_IGNORE_NODISCARD M().equal_range(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/equal_range2.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/equal_range2.fail.cpp +++ test/std/containers/associative/map/map.ops/equal_range2.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().equal_range(C2Int{5}); + TEST_IGNORE_NODISCARD M().equal_range(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/equal_range3.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/equal_range3.fail.cpp +++ test/std/containers/associative/map/map.ops/equal_range3.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().equal_range(C2Int{5}); + TEST_IGNORE_NODISCARD M().equal_range(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/find1.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/find1.fail.cpp +++ test/std/containers/associative/map/map.ops/find1.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().find(C2Int{5}); + TEST_IGNORE_NODISCARD M().find(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/find2.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/find2.fail.cpp +++ test/std/containers/associative/map/map.ops/find2.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().find(C2Int{5}); + TEST_IGNORE_NODISCARD M().find(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/find3.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/find3.fail.cpp +++ test/std/containers/associative/map/map.ops/find3.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().find(C2Int{5}); + TEST_IGNORE_NODISCARD M().find(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp +++ test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().lower_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().lower_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp +++ test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().lower_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().lower_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp +++ test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().lower_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().lower_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp +++ test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().upper_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().upper_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp +++ test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().upper_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().upper_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp =================================================================== --- test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp +++ test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp @@ -34,7 +34,7 @@ { typedef std::map M; - (void)M().upper_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().upper_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp @@ -33,6 +33,6 @@ { typedef std::multimap M; - (void)M().count(C2Int{5}); + TEST_IGNORE_NODISCARD M().count(C2Int{5}); } #endif Index: test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp @@ -33,6 +33,6 @@ { typedef std::multimap M; - (void)M().count(C2Int{5}); + TEST_IGNORE_NODISCARD M().count(C2Int{5}); } #endif Index: test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp @@ -33,6 +33,6 @@ { typedef std::multimap M; - (void)M().count(C2Int{5}); + TEST_IGNORE_NODISCARD M().count(C2Int{5}); } #endif Index: test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp @@ -33,6 +33,6 @@ { typedef std::multimap M; - (void)M().equal_range(C2Int{5}); + TEST_IGNORE_NODISCARD M().equal_range(C2Int{5}); } #endif Index: test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().equal_range(C2Int{5}); + TEST_IGNORE_NODISCARD M().equal_range(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().equal_range(C2Int{5}); + TEST_IGNORE_NODISCARD M().equal_range(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().find(C2Int{5}); + TEST_IGNORE_NODISCARD M().find(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().find(C2Int{5}); + TEST_IGNORE_NODISCARD M().find(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().find(C2Int{5}); + TEST_IGNORE_NODISCARD M().find(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().lower_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().lower_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().lower_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().lower_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().lower_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().lower_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().upper_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().upper_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().upper_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().upper_bound(C2Int{5}); } } #endif Index: test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp =================================================================== --- test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp +++ test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp @@ -34,7 +34,7 @@ { typedef std::multimap M; - (void)M().upper_bound(C2Int{5}); + TEST_IGNORE_NODISCARD M().upper_bound(C2Int{5}); } } #endif Index: test/std/containers/sequences/array/at.pass.cpp =================================================================== --- test/std/containers/sequences/array/at.pass.cpp +++ test/std/containers/sequences/array/at.pass.cpp @@ -50,7 +50,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void) c.at(3); + TEST_IGNORE_NODISCARD c.at(3); assert(false); } catch (const std::out_of_range &) {} @@ -69,7 +69,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void) c.at(3); + TEST_IGNORE_NODISCARD c.at(3); assert(false); } catch (const std::out_of_range &) {} Index: test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp =================================================================== --- test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp +++ test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp @@ -72,7 +72,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)c.at(11); + TEST_IGNORE_NODISCARD c.at(11); assert(false); } catch (std::out_of_range&) @@ -130,7 +130,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)c.at(11); + TEST_IGNORE_NODISCARD c.at(11); assert(false); } catch (std::out_of_range&) Index: test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/types.pass.cpp =================================================================== --- test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/types.pass.cpp +++ test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.overview/types.pass.cpp @@ -13,11 +13,12 @@ // Make sure that the error_code bits of are self-contained. #include +#include "test_macros.h" int main() { std::error_code x; - (void) x.category(); // returns a std::error_category & - (void) x.default_error_condition(); // std::error_condition - (void) x.message(); // returns a std::string + TEST_IGNORE_NODISCARD x.category(); // returns a std::error_category & + TEST_IGNORE_NODISCARD x.default_error_condition(); // std::error_condition + TEST_IGNORE_NODISCARD x.message(); // returns a std::string } Index: test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/types.pass.cpp =================================================================== --- test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/types.pass.cpp +++ test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.overview/types.pass.cpp @@ -13,10 +13,11 @@ // Make sure that the error_condition bits of are self-contained. #include +#include "test_macros.h" int main() { std::error_condition x = std::errc(0); - (void) x.category(); // returns a std::error_condition & - (void) x.message(); // returns a std::string + TEST_IGNORE_NODISCARD x.category(); // returns a std::error_condition & + TEST_IGNORE_NODISCARD x.message(); // returns a std::string } Index: test/std/iterators/iterator.range/begin-end.fail.cpp =================================================================== --- test/std/iterators/iterator.range/begin-end.fail.cpp +++ test/std/iterators/iterator.range/begin-end.fail.cpp @@ -43,9 +43,9 @@ int main(){ // Bug #28927 - shouldn't find these via ADL - (void) std::cbegin (Foo::FakeContainer()); - (void) std::cend (Foo::FakeContainer()); - (void) std::crbegin(Foo::FakeContainer()); - (void) std::crend (Foo::FakeContainer()); + TEST_IGNORE_NODISCARD std::cbegin (Foo::FakeContainer()); + TEST_IGNORE_NODISCARD std::cend (Foo::FakeContainer()); + TEST_IGNORE_NODISCARD std::crbegin(Foo::FakeContainer()); + TEST_IGNORE_NODISCARD std::crend (Foo::FakeContainer()); } #endif Index: test/std/iterators/iterators.general/gcc_workaround.pass.cpp =================================================================== --- test/std/iterators/iterators.general/gcc_workaround.pass.cpp +++ test/std/iterators/iterators.general/gcc_workaround.pass.cpp @@ -10,11 +10,12 @@ // Tests workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64816. #include +#include "test_macros.h" -void f(const std::string &s) { (void)s.begin(); } +void f(const std::string &s) { TEST_IGNORE_NODISCARD s.begin(); } #include -void AppendTo(const std::vector &v) { (void)v.begin(); } +void AppendTo(const std::vector &v) { TEST_IGNORE_NODISCARD v.begin(); } int main() {} Index: test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp =================================================================== --- test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp +++ test/std/iterators/predef.iterators/insert.iterators/insert.iterator/types.pass.cpp @@ -29,6 +29,7 @@ #include #include #include +#include "test_macros.h" template struct find_members @@ -38,7 +39,7 @@ void test() { this->container = 0; - (void)(this->iter == this->iter); + TEST_IGNORE_NODISCARD (this->iter == this->iter); } }; Index: test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp =================================================================== --- test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp +++ test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.nonmember/make_move_iterator.pass.cpp @@ -43,8 +43,8 @@ } { int a[] = {1,2,3,4}; - (void)std::make_move_iterator(a+4); - (void)std::make_move_iterator(a); // test for LWG issue 2061 + TEST_IGNORE_NODISCARD std::make_move_iterator(a+4); + TEST_IGNORE_NODISCARD std::make_move_iterator(a); // test for LWG issue 2061 } #if TEST_STD_VER > 14 Index: test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp =================================================================== --- test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp +++ test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include "test_macros.h" constexpr struct { int x; @@ -137,7 +138,7 @@ // LWG#2837 { auto res1 = std::lcm(static_cast(1234), INT32_MIN); - (void)std::lcm(INT_MIN, 2UL); // this used to trigger UBSAN + TEST_IGNORE_NODISCARD std::lcm(INT_MIN, 2UL); // this used to trigger UBSAN static_assert(std::is_same_v, ""); assert(res1 == 1324997410816LL); } Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp =================================================================== --- test/std/re/re.alg/re.alg.search/grep.pass.cpp +++ test/std/re/re.alg/re.alg.search/grep.pass.cpp @@ -33,7 +33,7 @@ std::regex::flag_type flag = std::regex_constants::grep; std::string s((const char *)data, size); std::regex re(s, flag); - (void)std::regex_match(s, re); + TEST_IGNORE_NODISCARD std::regex_match(s, re); } catch (std::regex_error &) {} } Index: test/std/re/re.grammar/excessive_brace_count.pass.cpp =================================================================== --- test/std/re/re.grammar/excessive_brace_count.pass.cpp +++ test/std/re/re.grammar/excessive_brace_count.pass.cpp @@ -20,7 +20,7 @@ for (std::regex_constants::syntax_option_type op : {std::regex::basic, std::regex::grep}) { try { - (void)std::regex("a\\{100000000000000000\\}", op); + TEST_IGNORE_NODISCARD std::regex("a\\{100000000000000000\\}", op); assert(false); } catch (const std::regex_error &e) { assert(e.code() == std::regex_constants::error_badbrace); @@ -30,7 +30,7 @@ {std::regex::ECMAScript, std::regex::extended, std::regex::egrep, std::regex::awk}) { try { - (void)std::regex("a{100000000000000000}", op); + TEST_IGNORE_NODISCARD std::regex("a{100000000000000000}", op); assert(false); } catch (const std::regex_error &e) { assert(e.code() == std::regex_constants::error_badbrace); Index: test/std/strings/basic.string/string.access/at.pass.cpp =================================================================== --- test/std/strings/basic.string/string.access/at.pass.cpp +++ test/std/strings/basic.string/string.access/at.pass.cpp @@ -35,7 +35,7 @@ { try { - (void)s.at(pos); + TEST_IGNORE_NODISCARD s.at(pos); assert(false); } catch (std::out_of_range&) @@ -44,7 +44,7 @@ } try { - (void)cs.at(pos); + TEST_IGNORE_NODISCARD cs.at(pos); assert(false); } catch (std::out_of_range&) Index: test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp =================================================================== --- test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp +++ test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp @@ -45,7 +45,7 @@ { try { - (void)s.compare(pos1, n1, sv, pos2, n2); + TEST_IGNORE_NODISCARD s.compare(pos1, n1, sv, pos2, n2); assert(false); } catch (const std::out_of_range&) @@ -69,7 +69,7 @@ { try { - (void)s.compare(pos1, n1, sv, pos2); + TEST_IGNORE_NODISCARD s.compare(pos1, n1, sv, pos2); assert(false); } catch (const std::out_of_range&) Index: test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp =================================================================== --- test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp +++ test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp @@ -40,7 +40,7 @@ { try { - (void)s.compare(pos1, n1, str); + TEST_IGNORE_NODISCARD s.compare(pos1, n1, str); assert(false); } catch (std::out_of_range&) Index: test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp =================================================================== --- test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp +++ test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp @@ -40,7 +40,7 @@ { try { - (void)s.compare(pos, n1, str, n2); + TEST_IGNORE_NODISCARD s.compare(pos, n1, str, n2); assert(false); } catch (std::out_of_range&) Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp =================================================================== --- test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp +++ test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp @@ -40,7 +40,7 @@ { try { - (void)s.compare(pos1, n1, str); + TEST_IGNORE_NODISCARD s.compare(pos1, n1, str); assert(false); } catch (std::out_of_range&) Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp =================================================================== --- test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp +++ test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp @@ -42,7 +42,7 @@ { try { - (void)s.compare(pos1, n1, str, pos2, n2); + TEST_IGNORE_NODISCARD s.compare(pos1, n1, str, pos2, n2); assert(false); } catch (const std::out_of_range&) @@ -65,7 +65,7 @@ { try { - (void)s.compare(pos1, n1, str, pos2); + TEST_IGNORE_NODISCARD s.compare(pos1, n1, str, pos2); assert(false); } catch (const std::out_of_range&) Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp =================================================================== --- test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp +++ test/std/strings/basic.string/string.ops/string_compare/size_size_string_view.pass.cpp @@ -40,7 +40,7 @@ { try { - (void)s.compare(pos1, n1, sv); + TEST_IGNORE_NODISCARD s.compare(pos1, n1, sv); assert(false); } catch (std::out_of_range&) Index: test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp =================================================================== --- test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp +++ test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp @@ -44,7 +44,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock(); + TEST_IGNORE_NODISCARD lk.try_lock(); assert(false); } catch (std::system_error& e) @@ -60,7 +60,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock(); + TEST_IGNORE_NODISCARD lk.try_lock(); assert(false); } catch (std::system_error& e) Index: test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp =================================================================== --- test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp +++ test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp @@ -49,7 +49,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock_for(ms(5)); + TEST_IGNORE_NODISCARD lk.try_lock_for(ms(5)); assert(false); } catch (std::system_error& e) @@ -65,7 +65,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock_for(ms(5)); + TEST_IGNORE_NODISCARD lk.try_lock_for(ms(5)); assert(false); } catch (std::system_error& e) Index: test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp =================================================================== --- test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp +++ test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp @@ -49,7 +49,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock_until(Clock::now()); + TEST_IGNORE_NODISCARD lk.try_lock_until(Clock::now()); assert(false); } catch (std::system_error& e) @@ -65,7 +65,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock_until(Clock::now()); + TEST_IGNORE_NODISCARD lk.try_lock_until(Clock::now()); assert(false); } catch (std::system_error& e) Index: test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp =================================================================== --- test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp +++ test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp @@ -43,7 +43,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock(); + TEST_IGNORE_NODISCARD lk.try_lock(); assert(false); } catch (std::system_error& e) @@ -59,7 +59,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock(); + TEST_IGNORE_NODISCARD lk.try_lock(); assert(false); } catch (std::system_error& e) Index: test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp =================================================================== --- test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp +++ test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp @@ -48,7 +48,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock_for(ms(5)); + TEST_IGNORE_NODISCARD lk.try_lock_for(ms(5)); assert(false); } catch (std::system_error& e) @@ -64,7 +64,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock_for(ms(5)); + TEST_IGNORE_NODISCARD lk.try_lock_for(ms(5)); assert(false); } catch (std::system_error& e) Index: test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp =================================================================== --- test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp +++ test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp @@ -48,7 +48,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock_until(Clock::now()); + TEST_IGNORE_NODISCARD lk.try_lock_until(Clock::now()); assert(false); } catch (std::system_error& e) @@ -64,7 +64,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)lk.try_lock_until(Clock::now()); + TEST_IGNORE_NODISCARD lk.try_lock_until(Clock::now()); assert(false); } catch (std::system_error& e) Index: test/std/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp =================================================================== --- test/std/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp +++ test/std/utilities/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp @@ -80,7 +80,7 @@ { #if !defined(TEST_HAS_NO_EXCEPTIONS) try { - (void)any_cast(a); + TEST_IGNORE_NODISCARD any_cast(a); assert(false); } catch (bad_any_cast const &) { // do nothing @@ -89,7 +89,7 @@ } try { - (void)any_cast(static_cast(a)); + TEST_IGNORE_NODISCARD any_cast(static_cast(a)); assert(false); } catch (bad_any_cast const &) { // do nothing @@ -103,7 +103,7 @@ typename std::remove_reference::type&&, Type >::type; - (void)any_cast(static_cast(a)); + TEST_IGNORE_NODISCARD any_cast(static_cast(a)); assert(false); } catch (bad_any_cast const &) { // do nothing @@ -111,13 +111,13 @@ assert(false); } #else - ((void)a); + (TEST_IGNORE_NODISCARD a); #endif } void test_cast_empty() { // None of these operations should allocate. - DisableAllocationGuard g; ((void)g); + DisableAllocationGuard g; (TEST_IGNORE_NODISCARD g); any a; checkThrows(a); } Index: test/std/utilities/any/any.nonmembers/make_any.pass.cpp =================================================================== --- test/std/utilities/any/any.nonmembers/make_any.pass.cpp +++ test/std/utilities/any/any.nonmembers/make_any.pass.cpp @@ -115,14 +115,14 @@ { { try { - (void)std::make_any(101); + TEST_IGNORE_NODISCARD std::make_any(101); assert(false); } catch (int const&) { } } { try { - (void)std::make_any({1, 2, 3}, 101); + TEST_IGNORE_NODISCARD std::make_any({1, 2, 3}, 101); assert(false); } catch (int const&) { } Index: test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp =================================================================== --- test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp +++ test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp @@ -23,7 +23,7 @@ { std::allocator a; try { - (void)a.allocate(count); + TEST_IGNORE_NODISCARD a.allocate(count); assert(false); } catch (const std::exception &) { } Index: test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp =================================================================== --- test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp +++ test/std/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp @@ -134,7 +134,7 @@ #ifndef TEST_HAS_NO_EXCEPTIONS try { - (void)ptr->shared_from_this(); + TEST_IGNORE_NODISCARD ptr->shared_from_this(); assert(false); } catch (std::bad_weak_ptr const&) { } catch (...) { assert(false); } Index: test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp =================================================================== --- test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp +++ test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.runtime.fail.cpp @@ -19,6 +19,6 @@ int main() { std::unique_ptr p(new int(3)); const std::unique_ptr& cp = p; - (void)(*p); // expected-error {{indirection requires pointer operand ('std::unique_ptr' invalid)}} - (void)(*cp); // expected-error {{indirection requires pointer operand ('const std::unique_ptr' invalid)}} + TEST_IGNORE_NODISCARD (*p); // expected-error {{indirection requires pointer operand ('std::unique_ptr' invalid)}} + TEST_IGNORE_NODISCARD (*cp); // expected-error {{indirection requires pointer operand ('const std::unique_ptr' invalid)}} } Index: test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp =================================================================== --- test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp +++ test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.fail.cpp @@ -16,12 +16,12 @@ void test_bad_index() { std::tuple t1; - (void)std::get(t1); // expected-error@tuple:* {{type not found}} - (void)std::get(t1); // expected-note {{requested here}} - (void)std::get(t1); // expected-note {{requested here}} + TEST_IGNORE_NODISCARD std::get(t1); // expected-error@tuple:* {{type not found}} + TEST_IGNORE_NODISCARD std::get(t1); // expected-note {{requested here}} + TEST_IGNORE_NODISCARD std::get(t1); // expected-note {{requested here}} // expected-error@tuple:* 2 {{type occurs more than once}} std::tuple<> t0; - (void)std::get(t0); // expected-node {{requested here}} + TEST_IGNORE_NODISCARD std::get(t0); // expected-node {{requested here}} // expected-error@tuple:* 1 {{type not in empty type list}} } Index: test/std/utilities/variant/variant.get/get_index.pass.cpp =================================================================== --- test/std/utilities/variant/variant.get/get_index.pass.cpp +++ test/std/utilities/variant/variant.get/get_index.pass.cpp @@ -259,7 +259,7 @@ auto test = [](auto idx, auto &&v) { using Idx = decltype(idx); try { - (void)std::get(std::forward(v)); + TEST_IGNORE_NODISCARD std::get(std::forward(v)); } catch (const std::bad_variant_access &) { return true; } catch (...) { /* ... */ Index: test/std/utilities/variant/variant.get/get_type.pass.cpp =================================================================== --- test/std/utilities/variant/variant.get/get_type.pass.cpp +++ test/std/utilities/variant/variant.get/get_type.pass.cpp @@ -259,7 +259,7 @@ auto test = [](auto idx, auto &&v) { using Idx = decltype(idx); try { - (void)std::get(std::forward(v)); + TEST_IGNORE_NODISCARD std::get(std::forward(v)); } catch (const std::bad_variant_access &) { return true; } catch (...) { /* ... */ Index: test/support/test_macros.h =================================================================== --- test/support/test_macros.h +++ test/support/test_macros.h @@ -189,6 +189,8 @@ #define LIBCPP_ONLY(...) ((void)0) #endif +#define TEST_IGNORE_NODISCARD (void) + namespace test_macros_detail { template struct is_same { enum { value = 0};} ;