First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 7189
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Steven Bosscher <steven@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: am-99173@konami.com
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 7189 depends on: Show dependency tree
Show dependency graph
Bug 7189 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2002-07-02 21:06
[gcc -O -Wall] reasonably prints a warning message complaining ``control
reaches end of non-void function''.  [gcc -O2 -Wall] should also print the same
warning message.  However, [gcc -O2 -Wall] silently succeeds.

cd /tmp
tar xfz gcc-3.1.tar.gz
mkdir /tmp/build
mkdir /tmp/experiment
cd /tmp/build
../gcc-3.1/configure \
    --prefix=/tmp/experiment \
    --enable-languages=c
make bootstrap
make install
cd /tmp
echo "extern void foo(void);" > chk.c
echo "int bar(void) { foo(); }" >> chk.c
/tmp/experiment/bin/gcc -S -O -Wall chk.c
  --> "warning: control reaches end of ..."
      (correct behavior)
/tmp/experiment/bin/gcc -S -O2 -Wall chk.c
  --> compilation silently succeeds
      (wrong behavior)

Release:
gcc version 3.1

Environment:
i686-pc-linux-gnu

How-To-Repeat:
extern void foo(void);
int bar(void) { foo(); }

------- Comment #1 From s.bosscher@student.tudelft.nl 2003-02-13 16:33 -------
From: Steven Bosscher <s.bosscher@student.tudelft.nl>
To: gcc-gnats@gcc.gnu.org, am99173@konami.com, gcc-bugs@gcc.gnu.org,
	nobody@gcc.gnu.org
Cc:  
Subject: Re: optimization/7189: gcc -O2 -Wall does not print ``control
	reaches end of non-void function'' warning
Date: 13 Feb 2003 16:33:14 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7189
 
 This is a sibling call optimization bug.
 
 Without any optimization (gcc -c -Wall), the warning is issued
 as it should be.  When sibling calls are optimized
 (gcc -c -Wall -foptimize-sibling-calls), the warning disappears.
 
 # cat c7129.c
 extern void foo(void);
 int bar(void) { foo(); }
 
 # gcc-3.4 -v
 Reading specs from
 /opt/experimental/lib/gcc-lib/i586-pc-linux-gnu/3.4/specs
 Configured with: ../gcc-trunk/configure --disable-nls --with-gnu-as
 --with-gnu-ld --prefix=/opt/experimental --program-suffix=-3.5
 --enable-languages=c,c++
 Thread model: posix
 gcc version 3.4 20030213 (experimental)
 # gcc-3.4 -c -Wall c7189.c                            
 c7189.c: In function `bar':
 c7189.c:2: warning: control reaches end of non-void function
 # gcc-3.4 -c -Wall c7189.c -foptimize-sibling-calls
 # 
 
 Greetz
 Steven
 
 


------- Comment #2 From s.bosscher@student.tudelft.nl 2003-02-13 22:04 -------
From: Steven Bosscher <s.bosscher@student.tudelft.nl>
To: gcc-gnats@gcc.gnu.org, am-99173@konami.com, gcc-bugs@gcc.gnu.org,
	nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org
Cc: rth@redhat.com
Subject: Re: optimization/7189: gcc -O2 -Wall does not print ``control
	reaches end of non-void function'' warning
Date: 13 Feb 2003 22:04:14 +0100

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7189
 
 This is a bug that happens when sibcall optimizations are performed.  It
 does not matter what other optimizations are enabled. When you do 
 gcc -O0 -Wall -foptimize-sibling-calls, the warning about the non-void
 function not returning anything doesn't show up.  The test case in the
 PR is: 
 
 extern void foo(void);
 int bar(void) { foo(); }
 
 Without sibcall optimization, the warning is issued.  The warning always
 shows up with gcc 2.95.3, so technically one could argue it's a
 regression... 
 
 The problem seems to be that after the sibcall optimizations, the cfg
 cleanup after jump optimizations also cleans up the clobber INSN for the
 function result (output for -c -Wall -foptimize-sibling-calls, todays
 mainline CVS): 
 
 --- c7189.c.01.sibling  Thu Feb 13 16:52:05 2003 
 +++ c7189.c.03.jump     Thu Feb 13 16:52:05 2003 
 @@ -1,14 +1,29 @@ 
 --- pass specific dump info cut out --- 
 @@ -27,19 +42,4 @@ 
 
 (barrier 11 10 14) 
 
 -(note 14 11 23 NOTE_INSN_FUNCTION_END) 
 - 
 -(note 23 14 18 1 [bb 1] NOTE_INSN_BASIC_BLOCK) 
 - 
 -(insn 18 23 19 1 (nil) (clobber (reg/i:SI 0 eax)) -1 (nil) 
 -    (nil)) 
 -    
 -(insn 19 18 17 1 (nil) (clobber (reg:SI 58 [ <result> ])) -1 (nil) 
 -    (nil)) 
 -    
 -(insn 17 19 20 1 (nil) (set (reg/i:SI 0 eax) 
 -        (reg:SI 58 [ <result> ])) -1 (nil) 
 -    (nil)) 
 - 
 -(insn 20 17 0 1 (nil) (use (reg/i:SI 0 eax)) -1 (nil) 
 -    (nil)) 
 +(note 14 11 0 NOTE_INSN_FUNCTION_END) 
 
 One way to "fix" this bug is to move check_function_return_warnings() up
 to before sibling call optimization in toplev.c, but maybe there's a
 more correct fix?
 
 Greetz
 Steven
 

------- Comment #3 From Eric Botcazou 2003-02-19 09:31 -------
State-Changed-From-To: open->analyzed
State-Changed-Why: Already analyzed by Steven.

------- Comment #4 From Richard Henderson 2003-02-28 16:29 -------
From: Richard Henderson <rth@redhat.com>
To: Steven Bosscher <s.bosscher@student.tudelft.nl>
Cc: gcc-gnats@gcc.gnu.org, am-99173@konami.com, gcc-bugs@gcc.gnu.org,
   nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org
Subject: Re: optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
Date: Fri, 28 Feb 2003 16:29:13 -0800

 On Thu, Feb 13, 2003 at 10:04:14PM +0100, Steven Bosscher wrote:
 > One way to "fix" this bug is to move check_function_return_warnings() up
 > to before sibling call optimization in toplev.c, but maybe there's a
 > more correct fix?
 
 I don't really like doing this earlier.  To get correct results
 we'd have to do an extra DCE pass, which seems wasteful wrt 
 compile-time for a warning.
 
 We should be able to detect this by looking at (1) predecessors
 of the EXIT block, (2) noticing that they end in a call_insn 
 with SIBLING_CALL_P set, and (3) noticing that the return value
 embedded in the call_insn is correct for the return value of
 the function.
 
 
 r~


------- Comment #5 From Richard Henderson 2003-02-28 16:30 -------
From: Richard Henderson <rth@redhat.com>
To: Steven Bosscher <s.bosscher@student.tudelft.nl>
Cc: gcc-gnats@gcc.gnu.org, am-99173@konami.com, gcc-bugs@gcc.gnu.org,
   nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org
Subject: Re: optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
Date: Fri, 28 Feb 2003 16:30:59 -0800

 On Thu, Feb 13, 2003 at 10:04:14PM +0100, Steven Bosscher wrote:
 > One way to "fix" this bug is to move check_function_return_warnings() up
 > to before sibling call optimization in toplev.c, but maybe there's a
 > more correct fix?
 
 I take that back.  Moving this to just after
 delete_unreachable_blocks should be just fine.
 
 
 r~


------- Comment #6 From s.bosscher@student.tudelft.nl 2003-03-01 23:55 -------
From: Steven Bosscher <s.bosscher@student.tudelft.nl>
To: Richard Henderson <rth@redhat.com>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
	gcc-patches@gcc.gnu.org, nobody@gcc.gnu.org
Subject: Re: optimization/7189: gcc -O2 -Wall does not print ``control
	reaches end of non-void function'' warning
Date: 01 Mar 2003 23:55:33 +0100

 Op za 01-03-2003, om 01:30 schreef Richard Henderson:
 > On Thu, Feb 13, 2003 at 10:04:14PM +0100, Steven Bosscher wrote:
 > > One way to "fix" this bug is to move check_function_return_warnings() up
 > > to before sibling call optimization in toplev.c, but maybe there's a
 > > more correct fix?
 > 
 > I take that back.  Moving this to just after
 > delete_unreachable_blocks should be just fine.
 
 I just bootstrapped all except Ada and treelang with the attached patch,
 regtesting now.  OK for mainline and 3.3 if it passes?
 
 Greetz
 Steven
 
 2003-03-01  Steven Bosscher  <s.bosscher@student.tudelft.nl>
 
 	PR optimization/7189
 	* toplev.c (rest_of_compilation):  Move
 	check_function_return_warnings up to just after
 	delete_unreachable_blocks.
 
 
 Index: toplev.c
 ===================================================================
 RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
 retrieving revision 1.725
 diff -c -3 -p -r1.725 toplev.c
 *** toplev.c	1 Mar 2003 01:21:22 -0000	1.725
 --- toplev.c	1 Mar 2003 22:43:44 -0000
 *************** rest_of_compilation (decl)
 *** 2625,2630 ****
 --- 2625,2634 ----
   
     delete_unreachable_blocks ();
   
 +   /* We have to issue these warnings now already, because CFG cleanups
 +      further down may destroy the required information.  */
 +   check_function_return_warnings ();
 + 
     /* Turn NOTE_INSN_PREDICTIONs into branch predictions.  */
     if (flag_guess_branch_prob)
       {
 *************** rest_of_compilation (decl)
 *** 3179,3186 ****
   
     open_dump_file (DFI_life, decl);
     regclass_init ();
 - 
 -   check_function_return_warnings ();
   
   #ifdef ENABLE_CHECKING
     verify_flow_info ();
 --- 3183,3188 ----
 


------- Comment #7 From Richard Henderson 2003-03-02 12:55 -------
From: Richard Henderson <rth@redhat.com>
To: Steven Bosscher <s.bosscher@student.tudelft.nl>
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org,
   nobody@gcc.gnu.org
Subject: Re: optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
Date: Sun, 2 Mar 2003 12:55:48 -0800

 On Sat, Mar 01, 2003 at 11:55:33PM +0100, Steven Bosscher wrote:
 > 	PR optimization/7189
 > 	* toplev.c (rest_of_compilation):  Move
 > 	check_function_return_warnings up to just after
 > 	delete_unreachable_blocks.
 
 Ok.
 
 Don't forget to add your testcase.
 
 
 r~


------- Comment #8 From Steven Bosscher 2003-03-10 12:48 -------
From: steven@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: optimization/7189
Date: 10 Mar 2003 12:48:09 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	steven@gcc.gnu.org	2003-03-10 12:48:09
 
 Modified files:
 	gcc            : toplev.c 
 
 Log message:
 	2003-03-10  Steven Bosscher  <s.bosscher@student.tudelft.nl>
 	
 	PR optimization/7189
 	* toplev.c (rest_of_compilation):  Move
 	check_function_return_warnings up to just after
 	delete_unreachable_blocks.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&r1=1.733&r2=1.734
 


------- Comment #9 From Steven Bosscher 2003-03-10 23:33 -------
From: steven@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: optimization/7189
Date: 10 Mar 2003 23:33:18 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	steven@gcc.gnu.org	2003-03-10 23:33:18
 
 Modified files:
 	gcc            : ChangeLog 
 
 Log message:
 	2003-03-10  Steven Bosscher  <s.bosscher@student.tudelft.nl>
 	
 	PR optimization/7189
 	* toplev.c (rest_of_compilation):  Move
 	check_function_return_warnings up to just after
 	delete_unreachable_blocks.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.17020&r2=1.17021
 

------- Comment #10 From Steven Bosscher 2003-03-11 20:09 -------
Responsible-Changed-From-To: unassigned->steven
Responsible-Changed-Why: Already fixed on mainline with my patch.  Waiting for approval for 3.3.  Will have to backport to 3.2 too...

------- Comment #11 From Steven Bosscher 2003-03-13 00:55 -------
From: steven@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: optimization/7189
Date: 13 Mar 2003 00:55:25 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	steven@gcc.gnu.org	2003-03-13 00:55:25
 
 Modified files:
 	gcc            : toplev.c 
 
 Log message:
 	2003-03-12  Steven Bosscher  <s.bosscher@student.tudelft.nl>
 	
 	PR optimization/7189
 	* toplev.c (rest_of_compilation):  Move
 	check_function_return_warnings up to just after
 	delete_unreachable_blocks.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.690.2.12&r2=1.690.2.13
 

------- Comment #12 From Joe Buck 2003-04-25 21:16 -------
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for 3.3.

First Last Prev Next    No search results available      Search page      Enter new bug