This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
(970929) reinterpret cast bug
- To: egcs-bugs at cygnus dot com
- Subject: (970929) reinterpret cast bug
- From: Mumit Khan <khan at xraylith dot wisc dot edu>
- Date: Wed, 01 Oct 1997 17:08:15 -0500
egcs snapshots don't like casting from "void *" to function pointers
even with the old sledgehammer namely reinterpret_cast; eg., the following
code doesn't work with any of the egcs snapshots (I've checked all the
snapshots to date). Does work with 2.7.2*.
The error I get is the following:
castbug.cc:4: reinterpret_cast from `void *' to `int (*)()'
======================================================================
typedef int (*intfun) (void);
void foo (void *fptr) {
intfun f = reinterpret_cast<intfun> (fptr);
}
======================================================================
% c++ -c -v castbug.cc
Reading specs from /scratch/src/gnu/lib/gcc-lib/i386-linux-gnulibc1/egcs-2.90.11/specs
gcc version egcs-2.90.11 970929 (gcc2-970802 experimental)
/scratch/src/gnu/lib/gcc-lib/i386-linux-gnulibc1/egcs-2.90.11/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Di386 -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__i386__ -Asystem(unix) -Acpu(i386) -Amachine(i386) castbug.cc /tmp/cca06252.ii
GNU CPP version egcs-2.90.11 970929 (gcc2-970802 experimental) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/scratch/src/gnu/include/g++
/usr/local/include
/scratch/src/gnu/i386-linux-gnulibc1/include
/scratch/src/gnu/lib/gcc-lib/i386-linux-gnulibc1/egcs-2.90.11/include
/usr/include
End of search list.
/scratch/src/gnu/lib/gcc-lib/i386-linux-gnulibc1/egcs-2.90.11/cc1plus /tmp/cca06252.ii -quiet -dumpbase castbug.cc -version -o /tmp/cca06252.s
GNU C++ version egcs-2.90.11 970929 (gcc2-970802 experimental) (i386-linux-gnulibc1) compiled by GNU C version egcs-2.90.11 970929 (gcc2-970802 experimental).
castbug.cc: In function `void foo(void *)':
castbug.cc:4: reinterpret_cast from `void *' to `int (*)()'
Regards,
Mumit -- khan@xraylith.wisc.edu
http://www.xraylith.wisc.edu/~khan/