This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Erronous warning in g++ compile
- To: <gcc-bugs at gcc dot gnu dot org>
- Subject: Erronous warning in g++ compile
- From: "Preston A. Elder" <prez at antisocial dot com>
- Date: Thu, 12 Apr 2001 11:38:25 -0400 (EDT)
Please try compiling this file with:
g++ -Wall -O -c compiler_error.cpp
For some reason, it tells me that I reach the end of a non-void function
without returning a value, when I obviously do. This does NOT occur if
I turn off optimization, or use -fno-default-inline.
This works with any class I've tested inside the vector. I've commented
the file well to highlight the error.
The GCC version I use is 2.95.2 19991024
The platform is Linux 2.4.x (i486-suse-linux).
Just thought you would like to know this warning is triggering erronously.
Thanks,
--
_O_ PreZ :) Finger prez@srealm.net.au _O_
| prez@goth.net for full PGP Public Key |
PGP FingerPrint: B3 0C F3 32 DE 5A 7D 90 26 F6 FA 38 CC 0A 2D D8
Goth Code '98: tSKeba5qaSabsaaaGbaa75KAASWGuajmsvbieqcL4BaaLb3F4
nId5mefqmDjmmgm#haxthgzpj4GiysNkycSRGHabiabOkauNSW
Magick Code .92: MWI S W++ N+ PCE/NA++ D A a+ C G QO+ 666 Y
/* Proof of bug in compiler ...
*
* The below will cause a 'reaches end of non-void function' warning when
* a class is used in the vector definition, and ANY inlining is done.
* This means any optimization is on, and -fno-default-inline is NOT
* defined. This code should NOT cause any warning.
*
* NOTE: This only occurs when the return is in {}'s, however there are
* times (for example when you want to #define a special return that does
* more than one thing, but still be able to use it after an if without
* having to put {}'s around it yourself) when you would want to put the
* return in {}'s (like I have done in my project that found this error).
*
* Also note, -Wall should be used in the compiler options to show up
* the problem.
*
* Bug found by Preston A. Elder <prez@antisocial.com>
*/
#include <vector>
class SomeClass {};
int SomeFunc()
{
vector<SomeClass> blah;
{ return 0; }
}