public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/32207]  New: inconsistent/missed warnings about address of 'x'.
@ 2007-06-04 16:59 pluto at agmk dot net
  2007-06-06 21:51 ` [Bug c/32207] missing " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pluto at agmk dot net @ 2007-06-04 16:59 UTC (permalink / raw)
  To: gcc-bugs

the following testcase express one condition in three different ways.
in fact, gcc produces only two different warnings.

extern void z();
void f() { if ( z ) z(); }
void g() { if ( z != 0 ) z(); }
void h() { if ( z != (void*)0 ) z(); }

t.c: In function 'f':
t.c:2: warning: the address of 'z' will always evaluate as 'true'
t.c: In function 'g':
t.c:3: warning: the address of 'z' will never be NULL


-- 
           Summary: inconsistent/missed warnings about address of 'x'.
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at agmk dot net
GCC target triplet: x86_64-linux


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


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

* [Bug c/32207] missing warnings about address of 'x'.
  2007-06-04 16:59 [Bug c/32207] New: inconsistent/missed warnings about address of 'x' pluto at agmk dot net
@ 2007-06-06 21:51 ` pinskia at gcc dot gnu dot org
  2008-02-05 19:32 ` pluto at agmk dot net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-06 21:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-06-06 21:51 -------
Confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2007-06-06 21:51:18
               date|                            |
            Summary|inconsistent/missed warnings|missing warnings about
                   |about address of 'x'.       |address of 'x'.


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


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

* [Bug c/32207] missing warnings about address of 'x'.
  2007-06-04 16:59 [Bug c/32207] New: inconsistent/missed warnings about address of 'x' pluto at agmk dot net
  2007-06-06 21:51 ` [Bug c/32207] missing " pinskia at gcc dot gnu dot org
@ 2008-02-05 19:32 ` pluto at agmk dot net
  2010-04-27  2:40 ` pzhao at gcc dot gnu dot org
  2010-04-27  2:42 ` pzhao at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pluto at agmk dot net @ 2008-02-05 19:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pluto at agmk dot net  2008-02-05 19:32 -------
for f()/g() it partially looks like missed transformation of `z!=0 => z`
in case of ADDR_EXPR which trigs different diagnotic:

f(): c-common.c: c_common_truthvalue_conversion with ADDR_EXPR.
g(): c-typeck.c: build_binary_op: case NE_EXPR, with op ADDR_EXPR.

for h() the -tree-original shows an ugly cast in `if`: (void*)z!=0
is it an expected behaviour?


-- 


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


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

* [Bug c/32207] missing warnings about address of 'x'.
  2007-06-04 16:59 [Bug c/32207] New: inconsistent/missed warnings about address of 'x' pluto at agmk dot net
  2007-06-06 21:51 ` [Bug c/32207] missing " pinskia at gcc dot gnu dot org
  2008-02-05 19:32 ` pluto at agmk dot net
@ 2010-04-27  2:40 ` pzhao at gcc dot gnu dot org
  2010-04-27  2:42 ` pzhao at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pzhao at gcc dot gnu dot org @ 2010-04-27  2:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pzhao at gcc dot gnu dot org  2010-04-27 02:40 -------
Subject: Bug 32207

Author: pzhao
Date: Tue Apr 27 02:40:19 2010
New Revision: 158765

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158765
Log:
gcc/
2010-04-27  Shujing Zhao  <pearly.zhao@oracle.com>

        PR c/32207
        * c-typeck.c (build_binary_op): Move forward check for comparison
        pointer with null pointer constant and adjust the diagnostic message.

gcc/testsuite/
2010-04-27  Shujing Zhao  <pearly.zhao@oracle.com>

        PR c/32207
        * gcc.dg/pr32207.c: New test.
        * gcc.dg/misc-column.c: Adjust expected warning.
        * gcc.dg/Walways-true-1.c: Likewise.
        * gcc.dg/Walways-true-2.c: Likewise.
        * gcc.dg/warn-addr-cmp.c: Likewise.


Added:
    trunk/gcc/testsuite/gcc.dg/pr32207.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/Walways-true-1.c
    trunk/gcc/testsuite/gcc.dg/Walways-true-2.c
    trunk/gcc/testsuite/gcc.dg/misc-column.c
    trunk/gcc/testsuite/gcc.dg/warn-addr-cmp.c


-- 


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


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

* [Bug c/32207] missing warnings about address of 'x'.
  2007-06-04 16:59 [Bug c/32207] New: inconsistent/missed warnings about address of 'x' pluto at agmk dot net
                   ` (2 preceding siblings ...)
  2010-04-27  2:40 ` pzhao at gcc dot gnu dot org
@ 2010-04-27  2:42 ` pzhao at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pzhao at gcc dot gnu dot org @ 2010-04-27  2:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pzhao at gcc dot gnu dot org  2010-04-27 02:42 -------
Fix for trunk.


-- 

pzhao at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2010-04-27  2:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-04 16:59 [Bug c/32207] New: inconsistent/missed warnings about address of 'x' pluto at agmk dot net
2007-06-06 21:51 ` [Bug c/32207] missing " pinskia at gcc dot gnu dot org
2008-02-05 19:32 ` pluto at agmk dot net
2010-04-27  2:40 ` pzhao at gcc dot gnu dot org
2010-04-27  2:42 ` pzhao 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).