G++ bug - static cast regression
Nathan Sidwell
nathan@acm.org
Fri Feb 4 05:12:00 GMT 2000
Hi,
The attached test case shows a recent regression in the static_cast
machinery. It's possibly something I did, I've not yet investigated.
nathan@manao:47>./g++ -B ./ -ansi -pedantic -c cast5.C
cast5.C: In function `void f0 (const char *const (*const &)[2])':
cast5.C:10: invalid static_cast from type `const char *const (*)[2]' to type `const void *'
cast5.C:11: invalid static_cast from type `const char *const (*)[2]' to type `void *'
cast5.C: In function `void f2 (const char *const (*&)[2])':
cast5.C:24: invalid static_cast from type `const char *const (*)[2]' to type `const void *'
cast5.C:25: invalid static_cast from type `const char *const (*)[2]' to type `void *'
lines 10 and 24 are the bogus errors. lines 11 and 25 are correct
(though a more informative diagnostic would be `casts away constness').
May I install it?
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
Never hand someone a gun unless you are sure where they will point it
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk
// Build don't link:
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 Feb 2000 <nathan@acm.org>
typedef char const *ary_t[2];
void f0 (ary_t const *const &ary)
{
static_cast <void const *> (ary); // gets bogus error - XFAIL *-*-*
static_cast <void *> (ary); // ERROR - casts away const
(void const *) (ary);
}
void f1 (ary_t *const &ary)
{
static_cast <void *> (ary);
static_cast <void const *> (ary);
(void const *) (ary);
}
void f2 (ary_t const *&ary)
{
static_cast <void const *> (ary); // gets bogus error - XFAIL *-*-*
static_cast <void *> (ary); // ERROR - casts away const
(void const *) (ary);
}
void f3 (ary_t *&ary)
{
static_cast <void *> (ary);
static_cast <void const *> (ary);
(void const *) (ary);
}
More information about the Gcc-bugs
mailing list