using __tm_atomic in template class member function

using __tm_atomic in template class member function

Ritratto di jiaq

There seems to be some problems when using __tm_atomic in template class member functions. I got errors whenever I put __tm_atomic regions in those functions. Here's the test case:

#include using namespace std;template
class Ptr{
private:
T *p;
public:
Ptr(T *x):p(x){}
int Equal(T *q){
__tm_atomic{}
return p==q?1:0;
}
};int main()
{
int a=3;
int *p_a=&a;
Ptr ptr_a(&a);
cout<}

And the error message is:

$ icpc -Qtm_enabled try_atomic.cpp
try_atomic.cpp(23): error: expected a "}"try_atomic.cpp(23): internal error: assertion failed at: "shared/edgcpfe/templates.c", line 2897

The code would compile if the class were not a template class. Is it a bug or that I shouldn't use it this way? Thanks.


btw, I'm using the Linux version of prototype edition 2.0

4 post / 0 new
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di jimdempseyatthecove

Jiaq,


First: Your Equal function should not require an atomic section.


Second: your __tm_atomic{} block is null


Third: if you wish to use atomic regardless then try:

int Equal(T *q){
return __tm_atomic{p==q?1:0;};
};
Jim Dempsey

Blog: The Parallel Void

www.quickthreadprogramming.com
Ritratto di jiaq

Hi, Jim,


Thanks very much for your instructions. However, the code is just a test case without any meaning, and I just made it as simple as possible. So pls ignore the semantics. I just want to show that there is an error whenever I put a whateveratomicsection in the function.


I also tried your code and itneither works.


It also fails on Windows with the same error message by the way.

Ritratto di Ravi Narayanaswamy (Intel)

This is a bug in current posted compiler. Will be addressed in the next compiler release.

Accedere per lasciare un commento.