From mboxrd@z Thu Jan 1 00:00:00 1970 From: gpoul@gnu.org To: gcc-gnats@gcc.gnu.org Cc: gpoul@gnu.org Subject: c/2699: gcc does not warn of dead code Date: Mon, 30 Apr 2001 11:56:00 -0000 Message-id: <200104301851.UAA22079@ddc.htl-tex.ac.at> X-SW-Source: 2001-04/msg00754.html List-Id: >Number: 2699 >Category: c >Synopsis: gcc does not warn of dead code >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: support >Submitter-Id: net >Arrival-Date: Mon Apr 30 11:56:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: root >Release: 3.1 20010430 (experimental) >Organization: >Environment: System: Linux ddc 2.2.17 #1 Sun Jun 25 09:24:41 EST 2000 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc/configure >Description: I'm currently reading the book "High Performance Computing" by ora and it has some interesting content about compiler optimization. In an exercise on p99 it asks the question "Does your compile give you a warning"? Then below this is a demo program with some code that can't be reached and I tried this with gcc and I wanted to notify you that gcc does not warn (at least not with -Wall) about dead code written by the user. As I already stated about I built it with gcc -Wall. I have also included the source of the program I used to test this. I think this might be a helpful feature but I don't really know if it's not already in there or if it isn't even possible. Therefore I chose to file this report as support instead of change-request. >How-To-Repeat: just compile the following source with gcc and it will not give you a compiler warning. - there is nothing more to repeat this :) #include int main () { int k=1; int v=0; if (k == 0) printf("This statement is never executed.\n"); return 0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: