This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Incomplete Type with static_cast
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Incomplete Type with static_cast
- From: Tasso Karkanis <tkarkanis at aw dot sgi dot com>
- Date: Wed, 05 Apr 2000 18:12:14 -0400
- Organization: Alias|Wavefront
There is a problem with g++ when applying the static_cast operator to
types that have been declared but not defined. The following command:
lnx-dev:~/tmp> g++ -v --save-temps -c static.C
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/cpp -lang-c++ -v -undef
-D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__
-Dunix -Di386 -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__
-D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -Asystem(posix)
-D__EXCEPTIONS -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386
-D__i386 -D__i386__ -D__tune_i386__ static.C static.ii
GNU CPP version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i386
Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/include/g++-2
/usr/i386-redhat-linux/include
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/cc1plus static.ii
-quiet -dumpbase static.cc -version -o static.s
GNU C++ version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
(i386-redhat-linux) compiled by GNU C version egcs-2.91.66
19990314/Linux (egcs-1.1.2 release).
static.C: In function `void f()':
static.C:6: static_cast from `int *' to `Goo *'
produced the file:
# 1 "static.C"
struct Goo;
void f()
{
int *p = 0;
Goo *r = static_cast<Goo *>( p );
}
This file compiles without warnings on lots of compilers (Microsoft
Visual C++ 5.0, SGI MIPSpro 7.2.1.2m, Sun Workshop Pro 4.2), but the HP
ANSI C++ B3910B A.03.13 give a message to the effect that static_cast
can only be applied to complete types, and fails to generate an object
file.
I don't know which behaviour is more standards compliant, but at the
very least, g++ should give a more meaningful error message.
--
**** Tasso Karkanis || Alias|Wavefront ****
*** tkarkanis@aw.sgi.com || 210 King St. East ***
** Ph: (416) 874-8660 || Toronto, Ontario **
* Fax: (416) 369-6154 || Canada M5A 1J7 *