[Bug c++/114104] nodiscard not diagnosed on synthesized operator!=
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jul 18 00:58:25 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114104
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:144b6099cdaa9ac1b298687c0cfdb06a970e338b
commit r15-2118-g144b6099cdaa9ac1b298687c0cfdb06a970e338b
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed Jul 17 20:57:54 2024 -0400
c++: missing -Wunused-value for !<expr> [PR114104]
Here we're neglecting to issue a -Wunused-value warning for suitable !
operator expressions, and in turn for != operator expressions that are
rewritten as !(x == y), only because we don't call warn_if_unused_value
on TRUTH_NOT_EXPR since its class is tcc_expression. This patch makes
us also consider warning for TRUTH_NOT_EXPR and also for ADDR_EXPR.
PR c++/114104
gcc/cp/ChangeLog:
* cvt.cc (convert_to_void): Call warn_if_unused_value for
TRUTH_NOT_EXPR and ADDR_EXPR as well.
gcc/testsuite/ChangeLog:
* g++.dg/warn/Wunused-20.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
More information about the Gcc-bugs
mailing list