Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Ricardo_F_1
Beginner
392 Views

error: declaration is incompatible (regparm involved)

hi, i'm trying to build a project (https://github.com/riclas/rstm/) with ICC but i get the following error:

libstm/txthread.cpp(138): error: declaration is incompatible with "__attribute((regparm(3))) bool (*volatile stm::TxThread::tmbegin)(stm::TxThread *)" (declared at line 152 of "include/stm/txthread.hpp")

    __attribute__((regparm(3))) bool (*volatile TxThread::tmbegin)(TxThread*) = begin_CGL;

 

txthread.cpp(138): bool TM_FASTCALL (*volatile TxThread::tmbegin)(TxThread*) = begin_CGL;

txthread.hpp(152): static TM_FASTCALL bool(*volatile tmbegin)(TxThread*);

TM_FASTCALL is a macro that expands into: __attribute__((regparm(3)))

This works fine in GCC. It also works if i don't define TM_FASTCALL, but then there are other problems, and i'm not sure if this is the root cause or not.

Thanks for any tips, cheers.

 

0 Kudos
5 Replies
Light_Intel
Moderator
392 Views

Hi Ricardo,

Can you please preprocess txthread.hpp for both gcc and icc and see what the macro TM_FASTCALL is being substituted with?

Regards,

Noga

Intel Developer Support

 

Judith_W_Intel
Employee
392 Views

 

This does looks like a bug.

Here is a small reproducer:

// gives error with icpc but not g++
#define TM_FASTCALL __attribute__((regparm(3)))

struct TxThread {
   static TM_FASTCALL void(*tmbegin)();
};

void TM_FASTCALL (*TxThread::tmbegin)();

 

Ricardo_F_1
Beginner
392 Views

thank you judith, i was trying to get the preprocessed headers, but compilers is not my strong suit.

Judith_W_Intel
Employee
392 Views

 

To preprocess on Linux you just need to add the -P option to your command line and the compiler will produce a file with the same name as the source file but it will have extension .i.  Then just attach the .i file to a note so we can see it.

Anyway, I entered this defect in our bug tracking database as DPD200381744.

As a workaround you should be able to declare it this way -- note the change in position in the definition.

#define TM_FASTCALL __attribute__((regparm(3)))

struct TxThread {
    static TM_FASTCALL void (*tmbegin)();
 };

void (TM_FASTCALL *TxThread::tmbegin)();

I think this is the recommended syntax in the GNU documentation.

 

 

Ricardo_F_1
Beginner
392 Views

your workaround does work, thanks. the positioning of the macro was inconsistent across the project, in some places it was already correct. glad to expose a bug though.

Reply