public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/32887]  New: memset warning
@ 2007-07-25  1:21 cnstar9988 at gmail dot com
  2007-07-25  2:43 ` [Bug middle-end/32887] " pinskia at gcc dot gnu dot org
                   ` (15 more replies)
  0 siblings, 16 replies; 18+ messages in thread
From: cnstar9988 at gmail dot com @ 2007-07-25  1:21 UTC (permalink / raw)
  To: gcc-bugs

gcc -O3 -Wall test.c
can gernerate warning on gcc-4.2.1 on x86.
but no warning on gcc-4.2.1/x64. even -m32 or -m64.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
        char x[20];

        memset(x,19,0);

        return 0;
}


-- 
           Summary: memset warning
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cnstar9988 at gmail dot com


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
@ 2007-07-25  2:43 ` pinskia at gcc dot gnu dot org
  2007-07-25  2:49 ` cnstar9988 at gmail dot com
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-25  2:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-07-25 02:43 -------
What is the warning that you are expecting?  We don't warn at all for memset
with a zero size.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
  2007-07-25  2:43 ` [Bug middle-end/32887] " pinskia at gcc dot gnu dot org
@ 2007-07-25  2:49 ` cnstar9988 at gmail dot com
  2007-07-25  9:09 ` pinskia at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: cnstar9988 at gmail dot com @ 2007-07-25  2:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from cnstar9988 at gmail dot com  2007-07-25 02:49 -------
why gcc show warnings on x86.
not show warnings on x64?
Bug?


-- 


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
  2007-07-25  2:43 ` [Bug middle-end/32887] " pinskia at gcc dot gnu dot org
  2007-07-25  2:49 ` cnstar9988 at gmail dot com
@ 2007-07-25  9:09 ` pinskia at gcc dot gnu dot org
  2007-07-25  9:13 ` cnstar9988 at gmail dot com
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-25  9:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2007-07-25 09:09 -------
(In reply to comment #2)
> why gcc show warnings on x86.

I am saying this does not warn in a normal FSF GCC release.  So what warning do
you expect?  A warning for a zero sized memset?  Well the FSF GCC does not warn
for that case at all.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (2 preceding siblings ...)
  2007-07-25  9:09 ` pinskia at gcc dot gnu dot org
@ 2007-07-25  9:13 ` cnstar9988 at gmail dot com
  2007-07-26  2:30 ` cnstar9988 at gmail dot com
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: cnstar9988 at gmail dot com @ 2007-07-25  9:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from cnstar9988 at gmail dot com  2007-07-25 09:13 -------
I download GCC from ftp.gnu.org, 4.2.1 release.

gcc -O3 -Wall test.c
can gernerate warning on gcc-4.2.1 on x86

but no warning on gcc-4.2.1/x64. even -m32 or -m64.

I only think the behavior on both platform is the same, because of same release
of GCC.


-- 


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (3 preceding siblings ...)
  2007-07-25  9:13 ` cnstar9988 at gmail dot com
@ 2007-07-26  2:30 ` cnstar9988 at gmail dot com
  2007-07-26  7:42 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: cnstar9988 at gmail dot com @ 2007-07-26  2:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from cnstar9988 at gmail dot com  2007-07-26 02:29 -------
Why the behavior on both platform is not the same? 
same code, same release of GCC.


-- 


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (4 preceding siblings ...)
  2007-07-26  2:30 ` cnstar9988 at gmail dot com
@ 2007-07-26  7:42 ` pinskia at gcc dot gnu dot org
  2007-07-26  7:46 ` cnstar9988 at gmail dot com
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-26  7:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2007-07-26 07:42 -------
> can gernerate warning on gcc-4.2.1 on x86
What is the warning?  Because I am not seeing it.
It might be that glibc is doing the warning.  Can you paste the warning you are
getting?


-- 


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (5 preceding siblings ...)
  2007-07-26  7:42 ` pinskia at gcc dot gnu dot org
@ 2007-07-26  7:46 ` cnstar9988 at gmail dot com
  2007-07-26  7:50 ` pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: cnstar9988 at gmail dot com @ 2007-07-26  7:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from cnstar9988 at gmail dot com  2007-07-26 07:45 -------
test.c:14: warning: statement with no effect

So I think it is gcc warning....


-- 


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (6 preceding siblings ...)
  2007-07-26  7:46 ` cnstar9988 at gmail dot com
@ 2007-07-26  7:50 ` pinskia at gcc dot gnu dot org
  2007-07-26  8:02 ` cnstar9988 at gmail dot com
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-26  7:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2007-07-26 07:50 -------
It might be, can you attach the preprocessed source?  Which you can find by
adding -save-temps and it will be either end in .i or .ii.  The difference in
glibc versions could be cause different warnings to show up in some cases, I
remember fixing statement with no effect for memset already in 4.2.0.


-- 


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (7 preceding siblings ...)
  2007-07-26  7:50 ` pinskia at gcc dot gnu dot org
@ 2007-07-26  8:02 ` cnstar9988 at gmail dot com
  2007-07-26  8:10 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: cnstar9988 at gmail dot com @ 2007-07-26  8:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from cnstar9988 at gmail dot com  2007-07-26 08:02 -------
Created an attachment (id=13980)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13980&action=view)
file

gcc -m32 -O3 -Wall test.c -save-temps


-- 


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (8 preceding siblings ...)
  2007-07-26  8:02 ` cnstar9988 at gmail dot com
@ 2007-07-26  8:10 ` pinskia at gcc dot gnu dot org
  2007-07-26  8:13 ` cnstar9988 at gmail dot com
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-07-26  8:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pinskia at gcc dot gnu dot org  2007-07-26 08:10 -------
This is a bug in glibc version  you are using, the warning is comming from the
expansion of a #define.  Looking at the expanded version, I see that glibc is
violating C aliasing rules anyways so the code might not always work.  


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (9 preceding siblings ...)
  2007-07-26  8:10 ` pinskia at gcc dot gnu dot org
@ 2007-07-26  8:13 ` cnstar9988 at gmail dot com
  2007-07-26  8:20 ` cnstar9988 at gmail dot com
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: cnstar9988 at gmail dot com @ 2007-07-26  8:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from cnstar9988 at gmail dot com  2007-07-26 08:13 -------
Created an attachment (id=13981)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13981&action=view)
(64bit)gcc -m32 -O3 -Wall test.c -save-temps



(64bit)gcc -m32 -O3 -Wall test.c -save-temps
In this platform, it's no warning.

why these with no warning?


-- 


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


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

* [Bug middle-end/32887] memset warning
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (10 preceding siblings ...)
  2007-07-26  8:13 ` cnstar9988 at gmail dot com
@ 2007-07-26  8:20 ` cnstar9988 at gmail dot com
  2007-07-26 13:57 ` [Bug middle-end/32887] warning for memset with zero size manu at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 18+ messages in thread
From: cnstar9988 at gmail dot com @ 2007-07-26  8:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from cnstar9988 at gmail dot com  2007-07-26 08:20 -------
I want the warning.
but why the warning is glibc's bug?

because memset(x,19,0), is buggy code.
I need the warning.


-- 

cnstar9988 at gmail dot com changed:

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


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


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

* [Bug middle-end/32887] warning for memset with zero size
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (11 preceding siblings ...)
  2007-07-26  8:20 ` cnstar9988 at gmail dot com
@ 2007-07-26 13:57 ` manu at gcc dot gnu dot org
  2007-07-26 16:51   ` Andrew Pinski
  2007-07-26 16:51 ` pinskia at gmail dot com
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 18+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-07-26 13:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from manu at gcc dot gnu dot org  2007-07-26 13:57 -------
(In reply to comment #12)
> I want the warning.
> but why the warning is glibc's bug?

Andrew already tried to explain. It is a side-effect of a bug in glibc.

> because memset(x,19,0), is buggy code.
> I need the warning.

I think that is a sensible feature request, am I missing something Andrew? 
I hope someone will be so kind to implement it for you (or you decide to
implement it yourself).


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
            Summary|memset warning              |warning for memset with zero
                   |                            |size


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


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

* Re: [Bug middle-end/32887] warning for memset with zero size
  2007-07-26 13:57 ` [Bug middle-end/32887] warning for memset with zero size manu at gcc dot gnu dot org
@ 2007-07-26 16:51   ` Andrew Pinski
  0 siblings, 0 replies; 18+ messages in thread
From: Andrew Pinski @ 2007-07-26 16:51 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs

On 26 Jul 2007 13:57:41 -0000, manu at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
> I think that is a sensible feature request, am I missing something Andrew?

memset with a zero size is valid code.

Thanks,
Andrew Pinski


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

* [Bug middle-end/32887] warning for memset with zero size
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (12 preceding siblings ...)
  2007-07-26 13:57 ` [Bug middle-end/32887] warning for memset with zero size manu at gcc dot gnu dot org
@ 2007-07-26 16:51 ` pinskia at gmail dot com
  2007-07-26 16:58 ` manu at gcc dot gnu dot org
  2007-09-10 14:07 ` pinskia at gcc dot gnu dot org
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gmail dot com @ 2007-07-26 16:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from pinskia at gmail dot com  2007-07-26 16:51 -------
Subject: Re:  warning for memset with zero size

On 26 Jul 2007 13:57:41 -0000, manu at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
> I think that is a sensible feature request, am I missing something Andrew?

memset with a zero size is valid code.

Thanks,
Andrew Pinski


-- 


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


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

* [Bug middle-end/32887] warning for memset with zero size
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (13 preceding siblings ...)
  2007-07-26 16:51 ` pinskia at gmail dot com
@ 2007-07-26 16:58 ` manu at gcc dot gnu dot org
  2007-09-10 14:07 ` pinskia at gcc dot gnu dot org
  15 siblings, 0 replies; 18+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-07-26 16:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from manu at gcc dot gnu dot org  2007-07-26 16:58 -------
(In reply to comment #14)
> Subject: Re:  warning for memset with zero size
> 
> On 26 Jul 2007 13:57:41 -0000, manu at gcc dot gnu dot org
> <gcc-bugzilla@gcc.gnu.org> wrote:
> >
> > I think that is a sensible feature request, am I missing something Andrew?
> 
> memset with a zero size is valid code.
> 

I am not saying that is invalid. I am saying that it is a statement with no
effect. So it could be warned as we warn for:  { 0; }
Perhaps memset with size 0 appears frequently in real-code as the result of
macro expansions or such. Then, this must be closed as WONTFIX and similar
requests can be directed at this PR.


-- 


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


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

* [Bug middle-end/32887] warning for memset with zero size
  2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
                   ` (14 preceding siblings ...)
  2007-07-26 16:58 ` manu at gcc dot gnu dot org
@ 2007-09-10 14:07 ` pinskia at gcc dot gnu dot org
  15 siblings, 0 replies; 18+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-09-10 14:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from pinskia at gcc dot gnu dot org  2007-09-10 14:07 -------


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


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-09-10 14:07 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-25  1:21 [Bug c/32887] New: memset warning cnstar9988 at gmail dot com
2007-07-25  2:43 ` [Bug middle-end/32887] " pinskia at gcc dot gnu dot org
2007-07-25  2:49 ` cnstar9988 at gmail dot com
2007-07-25  9:09 ` pinskia at gcc dot gnu dot org
2007-07-25  9:13 ` cnstar9988 at gmail dot com
2007-07-26  2:30 ` cnstar9988 at gmail dot com
2007-07-26  7:42 ` pinskia at gcc dot gnu dot org
2007-07-26  7:46 ` cnstar9988 at gmail dot com
2007-07-26  7:50 ` pinskia at gcc dot gnu dot org
2007-07-26  8:02 ` cnstar9988 at gmail dot com
2007-07-26  8:10 ` pinskia at gcc dot gnu dot org
2007-07-26  8:13 ` cnstar9988 at gmail dot com
2007-07-26  8:20 ` cnstar9988 at gmail dot com
2007-07-26 13:57 ` [Bug middle-end/32887] warning for memset with zero size manu at gcc dot gnu dot org
2007-07-26 16:51   ` Andrew Pinski
2007-07-26 16:51 ` pinskia at gmail dot com
2007-07-26 16:58 ` manu at gcc dot gnu dot org
2007-09-10 14:07 ` pinskia at gcc dot gnu dot 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).