From mboxrd@z Thu Jan 1 00:00:00 1970 From: fritz@intrinsity.com To: gcc-gnats@gcc.gnu.org Subject: c/3074: Statement with no effect not flagged with -Wall Date: Thu, 07 Jun 2001 07:56:00 -0000 Message-id: <20010607145104.26288.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg00226.html List-Id: >Number: 3074 >Category: c >Synopsis: Statement with no effect not flagged with -Wall >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Thu Jun 07 07:56:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Fritz Boehm >Release: gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) >Organization: >Environment: Red Hat Linux 7.1 >Description: This bug has to do with some statements with no effect going undetected by gcc. The line on line 4 of bug.c should (I believe) be flagged as a statement with no effect when run with -Wall. I munged the statement in two different ways (lines 5 and 6) which are correctly reported as statements with no effect. I have access to two linux boxes with different revisions of g++. Both yield the same results: 1491% gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) 1492% gcc -c bug.c -Wall bug.c: In function `main': bug.c:5: warning: statement with no effect bug.c:6: warning: statement with no effect 10% gcc -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) 11% gcc -c -Wall bug.c bug.c: In function `main': bug.c:5: warning: statement with no effect bug.c:6: warning: statement with no effect Another aspect that you might find interesting - there is assembly code generated for the apparently dead code at line 4. I'm not an x86 assembly wizard so I can't tell you what the code does, but there is extra code generated. I hope this helps. Feel free to email me with any questions. This is the first bug I've submitted for GNU tools (which I make use of extensively) so I hope I'm providing good feedback. >How-To-Repeat: gcc -c -Wall bug.c >Fix: Don't enter statements that have no effect :-D >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/x-tar; name="bug.tar.gz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="bug.tar.gz" H4sIALaNHzsAA+3UyWrDMBQFUG2tr7ikm7jQ5CnysDCh36KE1GhRFVSbQod/r5yEFkKHtGAXyj0b yfAeErKuNn272KpxiRGpKlGSlLbaj2LsYUxWtVFSW6mL2ha2HOrTTEFG3tdef9+5CKib6LvHL+p2 oZ1iO1PzocOt82Ge6yc9fLhGZyUuMXdYr2FyPB+nq7zBu+US4Q4PLgYfWlxh07fXp40fdqbGY5fO vlnjpFxncdf1MUAa/aL/+uD+ifTfFn7kNQ75Lz7PfyFv+S/FMP8TuoDBbLgE25n+7VuAs4KPs/IO xpyIiIiIiIiIiIiIiIiIiIjoR14BuO1YcQAoAAA=