Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 13.6 - VLA, 'volatile' and Rule Exception
#1
A qualifier in the declaration of an array applies to the element type, C11 6.7.3/9:
Quote:If the specification of an array type includes any type qualifiers, the element type is so-
qualified, not the array type.

Code:
uint32_t f1 (int32_t x) {

      volatile int32_t a1[x];
               int32_t a2[x];

      return sizeof (a1) + sizeof (a2);
    }

The Exception to this rule includes:
Quote:... is an lvalue with a volatile qualified type that is not a variable-length array...

Given that the qualifier applies to the element type and not the array type, "not a variable-length array" is always true for an lvalue with volatile type. Is it the intention for 'sizeof(a1)' to be non compliant and for 'sizeof(a2)' to be compliant?

The Exception could be seen to add to the set of non-compliant cases even though nothing is written explicitly in the Amplification or Rationale.

Regards,

Richard
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)