optimization/7189: gcc -O2 -Wall does not print ``control reaches end of non-void function'' warning

am-99173@konami.com am-99173@konami.com
Wed Jul 3 01:56:00 GMT 2002


>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:



More information about the Gcc-bugs mailing list