Domanda

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?

È stato utile?

Soluzione 2

IAR service pack 6.70.2 solved the problem.

Altri suggerimenti

We can tell from edg\lower_il.c that this is the EDG frontend, not a proprietary IAR parser. EDG is well-maintained and well-respected, and you can play with a newer version at http://gcc.godbolt.org/ . (Select ICC from the compiler menu.)

The filename suggests that it's dealing with a lower-level intermediate representation, not building the initial AST. There may be a problem translating the pointer-to-member access to more primitive operations. Or the flag might be appearing on the wrong line. Internal errors aren't always precise. An SSCCE would be better.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top