Bug 458981 - Function template results in internal compiler error (gcc 4.3.0-8)
Summary: Function template results in internal compiler error (gcc 4.3.0-8)
Keywords:
Status: CLOSED DUPLICATE of bug 458297
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 9
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-08-13 15:43 UTC by Stas Maximov
Modified: 2008-08-16 08:44 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-08-16 08:44:47 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Preprocessed source stored into /tmp/cc8VyqEJ.out file (1.03 KB, text/plain)
2008-08-13 15:43 UTC, Stas Maximov
no flags Details

Description Stas Maximov 2008-08-13 15:43:31 UTC
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) ---

Comment 1 Jakub Jelinek 2008-08-16 08:44:47 UTC

*** This bug has been marked as a duplicate of bug 458297 ***


Note You need to log in before you can comment on or make changes to this bug.