public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
[parent not found: <bug-21474-4@http.gcc.gnu.org/bugzilla/>]
* [Bug c/21474] New: missed optimizations when comparing address to NULL
@ 2005-05-09 17:22 trt at acm dot org
  2005-05-09 17:26 ` [Bug middle-end/21474] " pinskia at gcc dot gnu dot org
  2005-05-12 15:09 ` trt at acm dot org
  0 siblings, 2 replies; 4+ messages in thread
From: trt at acm dot org @ 2005-05-09 17:22 UTC (permalink / raw)
  To: gcc-bugs

The program below gives some expressions which gcc could, but does not, evaluate
to true.  E.g. gcc considers &p->a true, even when a is the first element
of the struct (is this a bug?), but does not consider &p->b[3] to be true.

struct foo {int a, b[10];};
 
int subr(int i, struct foo *p)
{
    int x[10];
 
#if 0
    // gcc folds this
    if (&p->a) return 1;
#else
    // but not these
    if (&p->b[3]) return 1;
 
    if (&x[3] != 0) return 1;
    if (&x[i] != 0) return 1;  // not sure if this one is safe to fold
#endif
    return 0;
}

-- 
           Summary: missed optimizations when comparing address to NULL
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: trt at acm dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2023-06-25 21:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-21474-4397@http.gcc.gnu.org/bugzilla/>
2007-11-15 17:03 ` [Bug middle-end/21474] missed optimizations when comparing address to NULL manu at gcc dot gnu dot org
     [not found] <bug-21474-4@http.gcc.gnu.org/bugzilla/>
2023-06-25 21:00 ` pinskia at gcc dot gnu.org
2005-05-09 17:22 [Bug c/21474] New: " trt at acm dot org
2005-05-09 17:26 ` [Bug middle-end/21474] " pinskia at gcc dot gnu dot org
2005-05-12 15:09 ` trt at acm 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).