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]

g++-2.95 rejects cast to void



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


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