public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
@ 2003-03-01 0:36 Richard Henderson
0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2003-03-01 0:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/7189; it has been noted by GNATS.
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~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
@ 2003-03-02 21:06 Richard Henderson
0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2003-03-02 21:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/7189; it has been noted by GNATS.
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~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
@ 2003-03-01 22:56 Steven Bosscher
0 siblings, 0 replies; 7+ messages in thread
From: Steven Bosscher @ 2003-03-01 22:56 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/7189; it has been noted by GNATS.
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 ----
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
@ 2003-03-01 0:36 Richard Henderson
0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2003-03-01 0:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/7189; it has been noted by GNATS.
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~
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
@ 2003-02-13 21:06 Steven Bosscher
0 siblings, 0 replies; 7+ messages in thread
From: Steven Bosscher @ 2003-02-13 21:06 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/7189; it has been noted by GNATS.
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
@ 2003-02-13 15:36 Steven Bosscher
0 siblings, 0 replies; 7+ messages in thread
From: Steven Bosscher @ 2003-02-13 15:36 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/7189; it has been noted by GNATS.
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
@ 2002-07-02 21:06 am-99173
0 siblings, 0 replies; 7+ messages in thread
From: am-99173 @ 2002-07-02 21:06 UTC (permalink / raw)
To: gcc-gnats
>Number: 7189
>Category: optimization
>Synopsis: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Tue Jul 02 21:06:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Honda Hiroki
>Release: gcc version 3.1
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
[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)
>How-To-Repeat:
extern void foo(void);
int bar(void) { foo(); }
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-03-02 21:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-01 0:36 optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning Richard Henderson
-- strict thread matches above, loose matches on Subject: below --
2003-03-02 21:06 Richard Henderson
2003-03-01 22:56 Steven Bosscher
2003-03-01 0:36 Richard Henderson
2003-02-13 21:06 Steven Bosscher
2003-02-13 15:36 Steven Bosscher
2002-07-02 21:06 am-99173
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).