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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-06-03
                 CC|                            |msebor at gcc dot gnu.org
          Component|c                           |c++
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed in C++.  The code that issues the warning is the same between C and
C++:

          if (COMPLETE_TYPE_P (elt_type)
              && !integer_onep (TYPE_SIZE_UNIT (elt_type))
              && domain != NULL_TREE
              && TYPE_MAX_VALUE (domain)
              && TYPE_MIN_VALUE (domain)
              && integer_zerop (TYPE_MIN_VALUE (domain))
              && integer_onep (fold_build2 (MINUS_EXPR, domain,
                                            arg2,
                                            TYPE_MAX_VALUE (domain))))
            warning_at (loc, OPT_Wmemset_elt_size,
                        "%<memset%> used with length equal to "
                        "number of elements without multiplication "
                        "by element size");

but the difference is that in C the domain of the zero-length array is [0,
null] while in C++ it's [0, SIZE_MAX].  I.e., TYPE_MAX_VALUE (domain) is null
in C which makes the if condition evaluate to false.

Reply via email to