public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/25151]  New: GCC issues warnings to a syntactically correct expression.
@ 2005-11-29  6:14 mishabear at gmail dot com
  2005-11-29  6:28 ` [Bug c/25151] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mishabear at gmail dot com @ 2005-11-29  6:14 UTC (permalink / raw)
  To: gcc-bugs

Put the following code in a file tt.c and compile tt.c with command "gcc -Wall
tt.c", then the compiler will complain.

int main()
{
        void *pv;

        pv = (pv=0);
        return 0;
}

The compiler complains:
tt.c: In function `main':
tt.c:5: warning: operation on `pv' may be undefined

The result of "gcc --version" is:
gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-52)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The result of "cat /etc/issue" is:
Red Hat Enterprise Linux AS release 3 (Taroon Update 5)
Kernel \r on an \m

The result of "uname -a" is:
Linux AS3-A64 2.4.21-32.EL #1 SMP Fri Apr 15 21:02:58 EDT 2005 x86_64 x86_64
x86_64 GNU/Linux

In fact the type of pv has no matter with the warning. The warning will still
show up if the type of pv is changed to int, short or double.


-- 
           Summary: GCC issues warnings to a syntactically correct
                    expression.
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mishabear at gmail dot com


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


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

* [Bug c/25151] GCC issues warnings to a syntactically correct expression.
  2005-11-29  6:14 [Bug c/25151] New: GCC issues warnings to a syntactically correct expression mishabear at gmail dot com
@ 2005-11-29  6:28 ` pinskia at gcc dot gnu dot org
  2005-11-29  7:44 ` mishabear at gmail dot com
  2006-09-18  1:38 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-29  6:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-11-29 06:28 -------
Note the warning is to warn things like:
a = a++;
which is syntactically correct but semantically questionable.

Note there are a lot of things which are syntactially correct but are
semantically questionable


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
      Known to fail|                            |4.0.3


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


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

* [Bug c/25151] GCC issues warnings to a syntactically correct expression.
  2005-11-29  6:14 [Bug c/25151] New: GCC issues warnings to a syntactically correct expression mishabear at gmail dot com
  2005-11-29  6:28 ` [Bug c/25151] " pinskia at gcc dot gnu dot org
@ 2005-11-29  7:44 ` mishabear at gmail dot com
  2006-09-18  1:38 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: mishabear at gmail dot com @ 2005-11-29  7:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from mishabear at gmail dot com  2005-11-29 07:44 -------
Subject: Re:  GCC issues warnings to a syntactically correct expression.

In fact I want to do something lik this:
int main()
{
        int ia[10];
        int *pi, i;

        i=10;
        pi = ( ((i>=0) && (i<10)) ? (pi=&(ia[i]), i=(i+1)%10, pi) : (pi=0) );
        return 0;
}

and I don't think there are any semantical problems.

29 Nov 2005 06:28:10 -0000, pinskia at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org>:
>
>
> ------- Comment #1 from pinskia at gcc dot gnu dot org  2005-11-29 06:28 -------
> Note the warning is to warn things like:
> a = a++;
> which is syntactically correct but semantically questionable.
>
> Note there are a lot of things which are syntactially correct but are
> semantically questionable
>
>
> --
>
> pinskia at gcc dot gnu dot org changed:
>
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>           Keywords|                            |diagnostic
>      Known to fail|                            |4.0.3
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25151
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>


-- 


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


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

* [Bug c/25151] GCC issues warnings to a syntactically correct expression.
  2005-11-29  6:14 [Bug c/25151] New: GCC issues warnings to a syntactically correct expression mishabear at gmail dot com
  2005-11-29  6:28 ` [Bug c/25151] " pinskia at gcc dot gnu dot org
  2005-11-29  7:44 ` mishabear at gmail dot com
@ 2006-09-18  1:38 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-18  1:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-09-18 01:38 -------
This code still involes undefined runtime behavior.  So the warning is valid.


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2006-09-18  1:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-29  6:14 [Bug c/25151] New: GCC issues warnings to a syntactically correct expression mishabear at gmail dot com
2005-11-29  6:28 ` [Bug c/25151] " pinskia at gcc dot gnu dot org
2005-11-29  7:44 ` mishabear at gmail dot com
2006-09-18  1:38 ` 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).