Search code examples
c++templatesarmiar

Using generic operator->* as rvalue


The compilation process of:

template <typename T> T GetMember(const T STRUCT_T::* member)
{
    STRUCT_T* pStruct = GetStruct();
    ...
    // read value
    T retVal = pStruct->*member; // compiler assertion here

    ReleaseStruct();

    return retVal;
}

ends due to compiler assertion when used with a non-basic type T:

Tool internal error: Internal Error: [Front end]: assertion failed at: "....\Translator\compiler_core\src\parser\edg\lower_il.c", line 13411

Shocked by the fact that IAR compiler's "lower_il.c" has at least 13,411 lines and non of them is a proper generic operator->*(), I found it even stranger that the following function do compile with a non-basic type T:

template <typename T> void SetMember(T STRUCT_T::* member, const T& value)
{
    STRUCT_T* pStruct = GetStruct();
    ...
    // write value
    pStruct->*member = value; // no compiler assertion here

    ReleaseStruct();    
}

I guess the result of the generic operator is OK as lvalue but not as rvalue. Unconsting the parameter didn't help.

Any ideas of cause and solution?


Solution

  • IAR service pack 6.70.2 solved the problem.