Welcome to Intel® Software Network Quick Login | Join | Help |
Search in Intel® Software Network Forums
in Go

Assertion in template.c

Last post 07-05-2008, 7:31 AM by jaab. 2 replies.
Sort Posts: Previous Next
 07-05-2008, 3:48 AM 30258325  

Assertion in template.c

Code below fails to compile w. intel C++ (10.0.026) .. I get the message:


bug.cpp(15): internal error: assertion failed at: "shared/edgcpfe/templates.c", line 5146
_p = Pair(pObject, &Stub< T , METHOD >);
^
compilation aborted for bug.cpp (code 4)


Any ideas?

//----------------------------------------------------------------------

#include <iostream>
#include <utility>

template < typename A0 >
class ZSignal
{
typedef void (*StubCall)(void*, A0);
typedef typename std::pair< void*, StubCall > Pair;

public:

template < typename T, void (T::*METHOD)(A0) >
void Register(T* pObject)
{
_p = Pair(pObject, &Stub< T , METHOD >);
}

void operator()(A0 a0) const
{
_p.second(_p.first, a0);
}

private:

template < typename T, void (T::*METHOD)(A0) >
static void Stub(void* pObject, A0 a0)
{
T* p = static_cast< T* >(pObject);
(p->*METHOD)(a0);
}

Pair _p;

};

class ZMyClass
{
public:
void MyMethod(int i) { std::cout << "MyMethod got : " << i << std::endl; }
};

int main()
{
ZSignal<int> d;
ZMyClass myClass;

d.Register<ZMyClass,&ZMyClass::MyMethod>(&myClass);
d(12);

return 0;
}

 
 07-05-2008, 6:58 AM 30258333 in reply to 30258325  

Re: Assertion in template.c

The ability to throw an internal error is sufficient justification for posting a problem report, regardless of whether you agree with the optional warning about unspecified order of evaluation.  That also would require you to be more specific about which compiler version you want to use.   If there is a fix, it would not likely be "back-ported" to 10.0.
 
 07-05-2008, 7:31 AM 30258337 in reply to 30258325  

Re: Assertion in template.c

oh well doesn't matter - i found the solution:

 by replacing the line:

 
_p = Pair(pObject, &Stub< T , METHOD >);

with two lines:

    StubCall c = &Stub<T,METHOD>;
    _p = Pair(pObject, c);


Cheers..


 
View as RSS news feed in XML

Shortcuts


Tags For This Post

...

Community Tags

...