https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114104

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Harald van Dijk from comment #2)
> For similar useless operations, such as f() ^ true;, GCC emits a similar
> warning "warning: value computed is not used [-Wunused-value]". Presumably,
> if that warning were implemented in GCC for ! as well, it should also fire
> for your original x != 0 test?
That sounds plausible.  The relevant code is

gcc/cp/cvt.cc
@@ -1647,11 +1647,6 @@ convert_to_void (tree expr, impl_conv_void implicit,
tsubst_flags_t complain)
              enum tree_code code = TREE_CODE (e);
              enum tree_code_class tclass = TREE_CODE_CLASS (code);
              if (tclass == tcc_comparison
                  || tclass == tcc_unary
                  || tclass == tcc_binary
                  || code == VEC_PERM_EXPR
                  || code == VEC_COND_EXPR)
                warn_if_unused_value (e, loc);

which doesn't consider boolean operations (TRUTH_NOT_EXPR / TRUTH_AND_EXPR /
TRUTH_OR_EXPR) because their class is tcc_expression.  This is probably just an
oversight (even the C front end warns for !f()).

Reply via email to