Dear all, I would like to post a bug report for the GNU C/C++ compiler 3.3-e500.
We use the compiler to generate code for a PowerPC processor. Used invokation line for the GNU C++ compiler: ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig -fmerge-templates -mmultiple -mno-string -mstrict-align -O3 -fno-exceptions -fno-rtti -fno-builtin-printf -I<different include paths> -D<differen #define's> X.CPP -oX.O // file X.CPP void f (int); typedef int* I; I f0 () { return static_cast<I>(f); } <--- line 5 I f1 () { return reinterpret_cast<I>(f); } <--- line 7 I f2 () { return (I)f; } // cast notation I f3 () { return I(f); } // functional notation The compiler gives the following error messages: X.CPP: In function `int* f0()': X.CPP:5: error: invalid static_cast from type `void ()(int)' to type `int*' X.CPP: In function `int* f1()': X.CPP:7: error: ISO C++ forbids casting between pointer-to-function and pointer-to-object I think the compiler should also reject the casts in f2() and f3(): - 5.4/5 states that the cast notation of explicit conversion performs only the conversions of a const_cast<>, of a static_cast<>, of reinterpret_cast<> and of certain combinations of those casts. - 5.2.3/1 says that cast in f3() is equivalent to the cast in f2(). Kind regards W. Roehrl -- Summary: C-style casts and function-style casts Product: gcc Version: 3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: wolfgang dot roehrl at gi-de dot com GCC build triplet: sparc-sun-solaris2.5.1 GCC host triplet: i386-pc-mingw32 GCC target triplet: powerpc-wrs-vxworks http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26030