public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/4691: Incorrect warning that statement has no effect
@ 2001-10-25 19:16 dgillies
  0 siblings, 0 replies; 2+ messages in thread
From: dgillies @ 2001-10-25 19:16 UTC (permalink / raw)
  To: gcc-gnats

>Number:         4691
>Category:       c
>Synopsis:       Incorrect warning that statement has no effect
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 25 19:16:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     dgillies@graviton.com <Donald W. Gillies>
>Release:        unknown-1.0
>Organization:
>Environment:
BSD 4.2 / Pentium II
>Description:
int func(void);
int func(void)
{
    return(1);
}

int func2(void);
int func2(void)
{
    return(1);
}

int OW_ReadDallasUID(void);
int OW_ReadDallasUID(void)
{
    unsigned int retry = 3;

    while ( retry ) {

        if (func()) {                // No devices found
            retry == 0;
            break;
        }
        if (func2()) {
            break;
        }
    }

    if (retry != 0) {
        return 1;
    }
    else {
        return 0;
    }
}

#ifdef compilation
cd /home/gillies/graviton/
gcc -v -DNDEBUG -DBOSON_TEST -g -fshort-enums -fshort-double -fno-common -pedant
ic-errors -W -Wall -Wimplicit -Wimplicit-int -Wreturn-type -Wswitch -Wunused -Ws
hadow -Wpointer-arith  -Wcast-align  -Waggregate-return -Wstrict-prototypes -Wmi
ssing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Werr
or -Wbad-function-cast -Wformat  -DTARGET_IS_FBAT onewirex.c
Using builtin specs.
gcc version 2.95.2 19991024 (release)
 /usr/libexec/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -Di386 -Dunix -D__
FreeBSD__=4 -D__FreeBSD_cc_version=420000 -D__i386__ -D__unix__ -D__FreeBSD__=4
-D__FreeBSD_cc_version=420000 -D__i386 -D__unix -Acpu(i386) -Amachine(i386) -Asy
stem(unix) -Asystem(FreeBSD) -g -W -Wall -Wimplicit -Wimplicit-int -Wreturn-type
 -Wswitch -Wunused -Wshadow -Wpointer-arith -Wcast-align -Waggregate-return -Wst
rict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -W
nested-externs -Werror -Wbad-function-cast -Wformat -pedantic-errors -Acpu(i386)
 -Amachine(i386) -Di386 -D__i386 -D__i386__ -D__ELF__ -DNDEBUG -DBOSON_TEST -DTA
RGET_IS_FBAT onewirex.c /tmp/ccn79828.i
GNU CPP version 2.95.2 19991024 (release) (i386 FreeBSD/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /usr/include/g++
End of omitted list.
 /usr/libexec/cc1 /tmp/ccn79828.i -quiet -dumpbase onewirex.c -g -W -Wall -Wimpl
icit -Wimplicit-int -Wreturn-type -Wswitch -Wunused -Wshadow -Wpointer-arith -Wc
ast-align -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-
declarations -Wredundant-decls -Wnested-externs -Werror -Wbad-function-cast -Wfo
rmat -pedantic-errors -version -fshort-enums -fshort-double -fno-common -o /tmp/
ccx79828.s
GNU C version 2.95.2 19991024 (release) (i386-unknown-freebsd) compiled by GNU C
 version 2.95.2 19991024 (release).
cc1: warnings being treated as errors
onewirex.c: In function `OW_ReadDallasUID':
onewirex.c:21: warning: statement with no effect

Compilation exited abnormally with code 1 at Thu Oct 25 19:09:53
#endif

> 














>How-To-Repeat:
The enclosed program produces a compiler warning
"statement has no effect".  However, i believe that
the statement gets us out of the loop and produces
a return code of 0 from the function.  there are
other ways out of the loop (func2()) that can produce
a return code of 1 from the function.  therefore,
it is not guaranteed that when we exit the loop
that (retry == 0), and later statements make use of
the retry variable to change control flow.

i believe the compilation warning is actually an
error in the dataflow analysis of the compiler.

- Don

P.S. this is a piece of stripped code, if you need the
original code, please email me (together with all the
grotesque includes, etc.)
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

* Re: c/4691: Incorrect warning that statement has no effect
@ 2001-10-25 23:41 neil
  0 siblings, 0 replies; 2+ messages in thread
From: neil @ 2001-10-25 23:41 UTC (permalink / raw)
  To: dgillies, gcc-bugs, gcc-prs, nobody

Synopsis: Incorrect warning that statement has no effect

State-Changed-From-To: open->closed
State-Changed-By: neil
State-Changed-When: Thu Oct 25 23:41:45 2001
State-Changed-Why:
    Not a bug.  Please look harder at the exact line the compiler
    claims has no effect - the compiler is entirely right.  8-)

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4691&database=gcc


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

end of thread, other threads:[~2001-10-25 23:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-25 19:16 c/4691: Incorrect warning that statement has no effect dgillies
2001-10-25 23:41 neil

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).