public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16794] New: should warn about switched memset arguments
@ 2004-07-28  6:41 martin at v dot loewis dot de
  2004-08-14  7:27 ` [Bug c/16794] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 4+ messages in thread
From: martin at v dot loewis dot de @ 2004-07-28  6:41 UTC (permalink / raw)
  To: gcc-bugs

gcc should issue a warning for the code

#include <string.h>

int main(int argc, char*argv[])
{
        memset(argv[0], strlen(argv[0]), 0);
        return 0;
}

as passes a size_t for the "int c" argument, and 0 for the "size_t n" argument.
This is a common programmming mistake, as the order of arguments to memset is
counter-intuitive. Trigger for this warning could either be that the size_t
argument is in the wrong position, or that a size of 0 is passed, making the
function call have no effect. The warning should hint that possibly the argument
order should be switched.

-- 
           Summary: should warn about switched memset arguments
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: martin at v dot loewis dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i486-linux
  GCC host triplet: i486-linux
GCC target triplet: i486-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16794


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/16794] should warn about switched memset arguments
  2004-07-28  6:41 [Bug c/16794] New: should warn about switched memset arguments martin at v dot loewis dot de
@ 2004-08-14  7:27 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-14  7:27 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-14 07:27 -------
This warning seems like it should not be done in the compiler at all because it really depends on if the 
person really wantted to write it this way (someone might have).

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16794


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/16794] should warn about switched memset arguments
       [not found] <bug-16794-4@http.gcc.gnu.org/bugzilla/>
@ 2023-03-31 11:42 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-03-31 11:42 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WONTFIX                     |DUPLICATE

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 61294

*** This bug has been marked as a duplicate of bug 61294 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/16794] should warn about switched memset arguments
       [not found] <bug-16794-25@http.gcc.gnu.org/bugzilla/>
@ 2007-09-10 14:07 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-10 14:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-09-10 14:07 -------
*** Bug 32887 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cnstar9988 at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16794


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-31 11:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-28  6:41 [Bug c/16794] New: should warn about switched memset arguments martin at v dot loewis dot de
2004-08-14  7:27 ` [Bug c/16794] " pinskia at gcc dot gnu dot org
     [not found] <bug-16794-25@http.gcc.gnu.org/bugzilla/>
2007-09-10 14:07 ` pinskia at gcc dot gnu dot org
     [not found] <bug-16794-4@http.gcc.gnu.org/bugzilla/>
2023-03-31 11:42 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).