This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++-2.95 rejects cast to void
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: g++-2.95 rejects cast to void
- From: Bruno Haible <haible at ilog dot fr>
- Date: Thu, 17 Jun 1999 00:01:10 +0200 (MET DST)
Hi,
G++ (gcc-2.95 19990602 prerelease) gives an error on the following code:
=================================================
struct foobar;
void bar (const foobar& x)
{
static_cast<void>(x); // ok
(void)x; // error message
}
=================================================
$ g++ -W -Wall -S bar.cc
bar.cc: In function `void bar(const foobar &)':
bar.cc:6: invalid use of undefined type `const struct foobar'
bar.cc:1: forward declaration of `const struct foobar'
After reading ANSI/ISO C++ section 5.4
The conversions performed by
--a static_cast (_expr.static.cast_),
...
can be performed using the cast notation of explicit type conversion.
it seems to me that g++ ought to grok the code without error message, just
like egcs-1.1 did.
Bruno