Bug 458981 - Function template results in internal compiler error (gcc 4.3.0-8)
Function template results in internal compiler error (gcc 4.3.0-8)
Status: CLOSED DUPLICATE of bug 458297
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
9
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-08-13 11:43 EDT by Stas Maximov
Modified: 2008-08-16 04:44 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-08-16 04:44:47 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Stas Maximov 2008-08-13 11:43:31 EDT
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 04:44:47 EDT

*** 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.