public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35973]  New: Incorrect warning: will never be executed
@ 2008-04-18 16:06 dot at dotat dot at
  2008-05-05  5:39 ` [Bug middle-end/35973] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dot at dotat dot at @ 2008-04-18 16:06 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2127 bytes --]

This bug exists in various forms in multiple versions of gcc:

$ cat gccbug.c

struct sel {
        const char  *name;
        unsigned int enabled;
};

int selog_on(struct sel *);

#define selog_on(sel) \
        (sel.enabled == 0 \
                ? selog_on(&sel) \
                : sel.enabled != 42)

void dostuff(int *);

void gccbug1(void) {
        struct sel sel = { "test", 0 };
        if(selog_on(sel)) {
                dostuff(0);
        }
}

void gccbug2(void) {
        struct sel sel = { "test", 0 };
        if(selog_on(sel)) {
                int i;
                dostuff(&i);
        }
}


$ gcc -O -Wunreachable-code -c gccbug.c
gccbug.c: In function `gccbug2':
gccbug.c:25: warning: will never be executed
$ gcc --version
gcc --version
gcc (GCC) 3.4.4 [FreeBSD] 20050518

$ gcc -O -Wunreachable-code -c gccbug.c
gccbug.c: In function ‘gccbug2’:
gccbug.c:24: warning: will never be executed
gccbug.c: In function ‘gccbug1’:
gccbug.c:17: warning: will never be executed
$ gcc -O -Werror -Wunreachable-code -c gccbug.c
cc1: warnings being treated as errors
gccbug.c: In function ‘gccbug2’:
gccbug.c:24: warning: will never be executed
$ gcc --version
gcc (GCC) 4.1.2 20070115 (prerelease) (SUSE Linux)

$ gcc -O -Wunreachable-code -c gccbug.c
gccbug.c: In function 'gccbug2':
gccbug.c:24: warning: will never be executed
gccbug.c: In function 'gccbug1':
gccbug.c:17: warning: will never be executed
$ gcc -O -Werror -Wunreachable-code -c gccbug.c
cc1: warnings being treated as errors
gccbug.c: In function 'gccbug2':
gccbug.c:24: warning: will never be executed
$ gcc --version
gcc (GCC) 4.2.1 20070719  [FreeBSD]


-- 
           Summary: Incorrect warning: will never be executed
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dot at dotat dot at
  GCC host triplet: i386-undermydesk-freebsd
GCC target triplet: i386-undermydesk-freebsd


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


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

end of thread, other threads:[~2008-12-28  6:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-18 16:06 [Bug c/35973] New: Incorrect warning: will never be executed dot at dotat dot at
2008-05-05  5:39 ` [Bug middle-end/35973] " pinskia at gcc dot gnu dot org
2008-05-05  5:41 ` pinskia at gcc dot gnu dot org
2008-05-05 14:53 ` dot at dotat dot at
2008-12-28  6:14 ` 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).