Created attachment 314218 [details] Preprocessed source stored into /tmp/cc8VyqEJ.out file When compiling the following C++ code (a), the compiler generates internal error (b). System and gcc versions are given in (c). Preprocessed source is attached. Thank you. --- begin (a) --- // // C callback test // extern "C" { typedef int (*ccb_callback_f)(void *arg); void ccb_register(ccb_callback_f, void *arg); int ccb_run(void); } // case4: member callback wrapped in a standalone class, using function // template deduction rules typedef void ccbwrapC_type; template<class R, class T, R (T::*pmf)(void)> struct ccbwrapC { static R func(void *arg) { T *ths = reinterpret_cast<T*>(arg); return (ths->*pmf)(); } static ccbwrapC_type *cast(T *ths) { return reinterpret_cast<ccbwrapC_type*>(ths); } }; template <class R, class T> R ( *ccbwrap4(R (T::*pmf)(void)) )(void *) { typedef ccbwrapC<R,T,pmf> gaga; return gaga::func; } struct C { int member_cb(void) { return 0; } C(void) { // instantiate the call back wrapper and use it ccb_register(ccbwrap4(&C::member_cb),(void*)this); } }; int main() { C gaga; ccb_run(); return 0; } --- end (a) --- --- begin (b) --- bash-3.2$ g++ -o ccb_test_main.o ccb_test_main.cpp ccb_test_main.cpp: In static member function ‘static R ccbwrapC<R, T, pmf>::func(void*) [with R = int, T = C, R (T::* pmf)() = pmf]’: ccb_test_main.cpp:21: internal compiler error: in expand_expr_real_1, at expr.c:7291 Please submit a full bug report, with preprocessed source if appropriate. See <http://bugzilla.redhat.com/bugzilla> for instructions. Preprocessed source stored into /tmp/cc8VyqEJ.out file, please attach this to your bugreport. --- end (b) --- --- begin (c) --- bash-3.2$ g++ --version g++ (GCC) 4.3.0 20080428 (Red Hat 4.3.0-8) Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. bash-3.2$ uname -a Linux host.net 2.6.25.11-97.fc9.i686 #1 SMP Mon Jul 21 01:31:09 EDT 2008 i686 i686 i386 GNU/Linux bash-3.2$ --- end (c) ---
*** This bug has been marked as a duplicate of bug 458297 ***