Complex Expressions


Type conversion rules sometimes refer to the notion of a complex expression. The term complex expression is defined in MISRA-C:2004 to mean any expression that is not:

In QAC the definition is more limited and refers to a non-constant expression whose value is directly computed from an arithmetic or bitwise operator, i.e. one of the following:

In MISRA-C:2004, the conversions that may be applied to complex expressions are restricted in order to fulfil the requirement that a sequence of arithmetic or bitwise operations in an expression should all be conducted in the same underlying type.

The following expressions are complex:

    s8a + s8b
    ~u16a
    u16a >> 2
    foo(2) + u8a
    *ppc + 1
    ++u8a

The following expressions are not complex, even though some contain complex sub-expressions:

    pc[u8a]
    foo(u8a + u8b)
    **ppuc
    *(ppc + 1)
    pcbuf[s16a * 2]
    u16a > u16b
    s8a && s8b

Index