9.17 Array and pointer extensions

The compiler supports a number of array and pointer extensions, for example permitting assignment between pointers to types that are interchangeable but not identical.

The following array and pointer extensions are supported:

  • Assignment and pointer differences are permitted between pointers to types that are interchangeable but not identical, for example, unsigned char * and char *. This includes pointers to same-sized integral types, typically, int * and long *. A warning is issued.

    Assignment of a string constant to a pointer to any kind of character is permitted without a warning.

  • Assignment of pointer types is permitted in cases where the destination type has added type qualifiers that are not at the top level, for example, assigning int ** to const int **. Comparisons and pointer difference of such pairs of pointer types are also permitted. A warning is issued.

  • In operations on pointers, a pointer to void is always implicitly converted to another type if necessary. Also, a null pointer constant is always implicitly converted to a null pointer of the right type if necessary. In ISO C, some operators permit these, and others do not.

  • Pointers to different function types can be assigned or compared for equality (==) or inequality (!=) without an explicit type cast. A warning or error is issued.

    This extension is prohibited in C++ mode.

  • A pointer to void can be implicitly converted to, or from, a pointer to a function type.

  • In an initializer, a pointer constant value can be cast to an integral type if the integral type is big enough to contain it.

  • A non lvalue array expression is converted to a pointer to the first element of the array when it is subscripted or similarly used.

Non-ConfidentialPDF file icon PDF versionARM DUI0472M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.