This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: bug report...
- To: Joe Buck <jbuck at synopsys dot com>
- Subject: Re: bug report...
- From: Branko Cibej <branko dot cibej at hermes dot si>
- Date: Tue, 09 Jun 1998 09:07:47 +0200
- Cc: "B. James Phillippe" <bryan at terran dot org>, oliva at dcc dot unicamp dot br, egcs at cygnus dot com
- Organization: HERMES SoftLab
- References: <199806061911.MAA23958@atrus.synopsys.com>
Joe Buck wrote:
> Ideally, the -ansi flag should warn about use of extensions (that
> doesn't mean it currently does in every case) and -ansi -pedantic
> should make the compiler really nitpicky about deviations from the
> standard. Again, because the language is so big I'm sure egcs has
> missed a lot of these things.
Speaking of deviations from the standard; I _think_ the C++ FDIS allows an
expression on a return statement in a function returning void, and that this was
allowed specifically to simplify writing templates, e.g.:
------void.cc begins------
template <typename R> class functor {
public:
functor (R (*fn) ())
: func(fn)
{}
R operator() ()
{
return func ();
}
private:
R (*func) ();
};
int foo () { return 1; }
void bar () {}
int main ()
{
functor<int> f(foo);
functor<void> b(bar);
f();
b();
return 0;
}
------void.cc ends------
Egcs snapshot 1998-05-31 has this to say about the code above:
$ /home/brane/eval/egcs/bin/gcc -v
Reading specs from /home/brane/eval/egcs/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.34/specs
gcc version egcs-2.91.34 19980530 (gcc2 ss-980502 experimental)
$ home/brane/eval/egcs/bin/c++ -ansi -pedantic -o void void.cc
void.cc: In method `void functor<void>::operator ()<void>()':
void.cc:25: instantiated from here
void.cc:9: warning: `return' with a value, in function returning void
Should this really be a pedantic warning?
Brane
--
Branko Cibej <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
phone: (++386 61) 186 53 49 fax: (++386 61) 186 52 70