This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

pre1.0.2: "warning: control reaches end of non-void function" bug ??


Hi,

when you compile the following programm with gcc you will correctly get two
warnings about missing return values. But when you compile the same programm
with c++ or g++ the warning in main() is missing.
Bug or feature ? 


Tesprogramm "ret1.c"
-------------------------------------------------------------------------
int f()
{
}
int main()
{
}
-------------------------------------------------------------------------


Wrong output of "g++ -v -Wall -c ret1.c":
-------------------------------------------------------------------------
Reading specs from /usr/local/soft/egcs-pre1.0.2-980302/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.25/specs
gcc version egcs-2.90.25 980302 (egcs-1.0.2 prerelease)
 /usr/local/soft/egcs-pre1.0.2-980302/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.25/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posi
x) -D__EXCEPTIONS -Wall -Di386 -Di586 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -D__i586__ -Asystem(unix) -Acpu(i386) -Amachine(i386) ret1.c /tmp/cca22163.ii
GNU CPP version egcs-2.90.25 980302 (egcs-1.0.2 prerelease) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/soft/egcs-pre1.0.2-980302/include/g++
 /usr/local/include
 /usr/local/soft/egcs-pre1.0.2-980302/i586-pc-linux-gnu/include
 /usr/local/soft/egcs-pre1.0.2-980302/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.25/include
 /usr/include
End of search list.
 /usr/local/soft/egcs-pre1.0.2-980302/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.25/cc1plus /tmp/cca22163.ii -quiet -dumpbase ret1.cc -Wall -version -o /tmp/cca22163.s
GNU C++ version egcs-2.90.25 980302 (egcs-1.0.2 prerelease) (i586-pc-linux-gnu) compiled by GNU C version egcs-2.90.25 980302 (egcs-1.0.2 prerelease).
ret1.c: In function `int f()':
ret1.c:3: warning: control reaches end of non-void function `f()'
 as -V -Qy -o ret1.o /tmp/cca22163.s
GNU assembler version 2.8.1 (i686-pc-linux-gnu), using BFD version linux-2.8.1.0.1
-------------------------------------------------------------------------


Correct output of "gcc -v -Wall -c ret1.c":
-------------------------------------------------------------------------
Reading specs from /usr/local/soft/egcs-pre1.0.2-980302/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.25/specs
gcc version egcs-2.90.25 980302 (egcs-1.0.2 prerelease)
 /usr/local/soft/egcs-pre1.0.2-980302/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.25/cpp -lang-c -v -undef -D__GNUC__=2 -D__GNUC_MINOR__=90 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -Wall -Di386 -Di586 -Asyst
em(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -D__i586__ -Asystem(unix) -Acpu(i386) -Amachine(i386) ret1.c /tmp/cca22170.i
GNU CPP version egcs-2.90.25 980302 (egcs-1.0.2 prerelease) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/soft/egcs-pre1.0.2-980302/i586-pc-linux-gnu/include
 /usr/local/soft/egcs-pre1.0.2-980302/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.25/include
 /usr/include
End of search list.
 /usr/local/soft/egcs-pre1.0.2-980302/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.90.25/cc1 /tmp/cca22170.i -quiet -dumpbase ret1.c -Wall -version -o /tmp/cca22170.s
GNU C version egcs-2.90.25 980302 (egcs-1.0.2 prerelease) (i586-pc-linux-gnu) compiled by GNU C version egcs-2.90.25 980302 (egcs-1.0.2 prerelease).
ret1.c: In function `f':
ret1.c:3: warning: control reaches end of non-void function
ret1.c: In function `main':
ret1.c:6: warning: control reaches end of non-void function
 as -V -Qy -o ret1.o /tmp/cca22170.s
GNU assembler version 2.8.1 (i686-pc-linux-gnu), using BFD version linux-2.8.1.0.1
-------------------------------------------------------------------------


cu
		Michael


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]