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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-01-07
           Keywords|                            |diagnostic
             Blocks|                            |89863
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The docs explain why GCC's -Wmemset-transposed-args doesn't warn:

  Warn for suspicious calls to the "memset" built-in function where the second
  argument is not zero and the third argument is zero.  For example, the call
  "memset (buf, sizeof buf, 0)" is diagnosed because "memset (buf, 0, sizeof
  buf)" was meant instead.  The diagnostic is only emitted if the third
argument
  is a literal zero.

So not warning for your case is by design.

But it probably makes sense to warn if the second argument is a sizeof
expression, whatever the value of the third argument.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89863
[Bug 89863] [meta-bug] Issues in gcc that other static analyzers (cppcheck,
clang-static-analyzer, PVS-studio) find that gcc misses

Reply via email to