2.4. Arm C Implementation Defined Behavior

The C standard requires that conforming implementations provide documentation on how the compiler handles instances of implementation-defined behavior.

The TI Arm Clang compiler officially supports a freestanding environment. The C standard does not require a freestanding environment to supply every C feature; in particular the library need not be complete. However, the TI compiler strives to provide most features of a hosted environment.

The section numbers in the lists that follow correspond to section numbers in Appendix J of the C99 standard and Appendix J of the C11 standard. The numbers in parentheses at the end of each item are sections in each standard that discuss the topic. Certain items listed in Appendix J of the C99 standard have been omitted from this list.

2.4.1. Translation (J.3.1)

  • The compiler and related tools emit diagnostic messages with several distinct formats. The more common form is the following:

    source-file:line-number:char-number: description [diagnostic-flag]

    Where ‘description’ is a text description of the error, and ‘diagnostic-flag’ is an option flag of the form -Wflag for messages that can be suppressed. (1.3.6)

  • Diagnostic messages are emitted to stderr; any text on stderr may be assumed to be a diagnostic. If any errors are present, the tool will exit with an exit status indicating failure (non-zero). (C99/C11 3.10, 5.1.1.3)

  • Each whitespace sequence is collapsed to a single space. For aesthetic reasons, the first token on each non-directive line of output is preceded with sufficient spaces that it appears in the same column as it did in the original source file. (C99/C11 5.1.1.2)

2.4.2. Environment (J.3.2)

  • The compiler interprets the physical source file multibyte characters as UTF-8.

    Wide character (wchar_t) types and operations are supported by the compiler. However, wide character strings may not contain characters beyond 7-bit ASCII. The encoding of wide characters is 7-bit ASCII, 0 extended to the width of the wchar_t type. (C99/C11 5.1.1.2)

  • The name of the function called at program startup is main. Its parameter list may be (void) or (int argc, char *argv[]). (C99/C11 5.1.2.1)

  • Program termination does not affect the environment; there is no way to return an exit code to the environment. By default, the program is known to have halted when execution reaches the special C$$EXIT label. (C99/C11 5.1.2.1)

  • In relaxed ANSI mode, the compiler accepts void main(void) and void main(int argc, char *argv[]) as alternate definitions of main. The alternate definitions are rejected in strict ANSI mode. (C99/C11 5.1.2.2.1)

  • If space is provided for program arguments at link time with the --args option and the program is run under a system that can populate the .args section (such as CCS), argv[0] will contain the filename of the executable, argv[1] through argv[argc-1] will contain the command-line arguments to the program, and argv[argc] will be NULL. Otherwise, the value of argv and argc are undefined. (C99/C11 5.1.2.2.1)

  • Interactive devices include stdin, stdout, and stderr (when attached to a system that honors CIO requests). Interactive devices are not limited to those output locations; the program may access hardware peripherals that interact with the external state. (C99/C11 5.1.2.3)

  • Signals are not supported. The function signal is not supported. (C99/C11 7.14, 7.14.1.1)

  • The library function getenv is implemented through the CIO interface. If the program is run under a system that supports CIO, the system performs getenv calls on the host system and passes the result back to the program. Otherwise the operation of getenv is undefined. No method of changing the environment from inside the target program is provided. (C99 7.20.4.5, C11 7.22.4.6)

  • The system function is not supported. (C99 7.20.4.6, C11 7.22.4.8)

2.4.3. Identifiers (J.3.3)

  • Multibyte characters are allowed in identifiers whose UTF-8 decoded value is within the allowed ranges specified in Appendix D of ISO/IEC 9899:2011. The ‘$’ character is allowed in identifiers.

  • The number of significant initial characters in an identifier is unlimited. (C99/C11 5.2.4.1, 6.4.2)

2.4.4. Characters (J.3.4)

  • The number of bits in a byte (CHAR_BIT) is 8. (C99/C11 3.6)

  • The execution character set is the same as the basic execution character set: plain ASCII. Characters in the ISO 8859 extended character set are also supported. (C99/C11 5.2.1)

  • The values produced for the standard alphabetic escape sequences are as follows: (C99/C11 5.2.2)

Escape Sequence

ASCII Meaning

Integer Value

\a

BEL (bell)

7

\b

BS (backspace)

8

\f

FF (form feed)

12

\n

LF (line feed)

10

\r

CR (carriage return)

13

\t

HT (horizontal tab)

9

\v

VT (vertical tab)

11

  • The value of a char object into which any character other than a member of the basic execution character set has been stored is the ASCII value of that character. (C99/C11 6.2.5)

  • Plain char is identical to unsigned char, but can be changed to signed char with the -fsigned-char option. (C99/C11 6.2.5, 6.3.1.1)

  • The source character set and execution character set are identical. (C99/C11 6.4.4.4, 5.1.1.2)

  • The value of an integer character constant containing more than one character is the same as the last source character. The compiler will emit a warning when an integer character constant containing more than one character is used. There are no characters or escape sequences that do not map to a single-byte execution character. (C99/C11 6.4.4.4)

  • The compiler does not support multibyte characters in wide character constants. There are no wide characters or escape sequences that do not map to a single wide execution character. (C99/C11 6.4.4.4)

  • The compiler currently supports only one locale, “C”. (C99/C11 6.4.4.4)

  • The compiler currently supports only one locale, “C”. (C99/C11 6.4.5)

  • The compiler does not support multibyte characters in string literals. There are no escape sequences that do not map to a single execution character. (C99/C11 6.4.5)

  • The wchar_t type is 32-bits wide and is equivalent to the uint32_t type (unsigned int).

2.4.5. Integers (J.3.5)

  • No extended integer types are supported. (C99/C11 6.2.5)

  • Negative values for signed integer types are represented as two’s complement, and there are no trap representations. (C99/C11 6.2.6.2)

  • No extended integer types are supported, so there is no change to the integer ranks. (C99/C11 6.3.1.1)

  • When an integer is converted to a signed integer type which cannot represent the value, the value is truncated (without raising a signal) by discarding the bits which cannot be stored in the destination type; the lowest bits are not modified. (C99/C11 6.3.1.3)

  • Right shift of a signed integer value performs an arithmetic (signed) shift. The bitwise operations other than right shift operate on the bits in exactly the same way as on an unsigned value. That is, after the usual arithmetic conversions, the bitwise operation is performed without regard to the format of the integer type, in particular the sign bit. (C99/C11 6.5)

2.4.6. Floating Point (J.3.6)

  • The accuracy of floating-point operations (+ - * /) is bit-exact. The accuracy of library functions that return floating-point results is not specified. (C99/C11 5.2.4.2.2)

  • The accuracy of the conversions between floating-point internal representations and string representations performed by the library functions in <stdio.h>, <stdlib.h>, and <wchar.h> is not specified. (C11 5.2.4.2.2)

  • The compiler does not provide non-standard values for FLT_ROUNDS (C99/C11 5.2.4.2.2)

  • The compiler does not provide non-standard negative values of FLT_EVAL_METHOD (C99/C11 5.2.4.2.2)

  • The rounding direction when an integer is converted to a floating-point number is IEEE-754 “round to even”. (C99/C11 6.3.1.4)

  • The rounding direction when a floating-point number is converted to a narrower floating-point number is IEEE-754 “round to even”. (C99/C11 6.3.1.5)

  • For floating-point constants that are not exactly representable, the implementation uses the nearest representable value. (C99/C11 6.4.4.2)

  • The compiler does not contract float expressions, except when -ffast-math is used. (C99/C11 6.5)

  • The default state for the FENV_ACCESS pragma is off. (C99/C11 7.6.1)

  • The compiler does not define any additional float exceptions (C99/C11 7.6, 7.12)

  • The default state for the FP_CONTRACT pragma is off. (C99/C11 7.12.2)

  • The “inexact” floating-point exception cannot be raised if the rounded result equals the mathematical result. (F.9)

  • The “underflow” and “inexact” floating-point exceptions cannot be raised if the result is tiny but not inexact. (F.9)

2.4.7. Arrays and Pointers (J.3.7)

  • When converting a pointer to an integer or vice versa, the pointer is considered an unsigned integer of the same size, and the normal integer conversion rules apply. If the bitwise representation of the destination can hold all of the bits in the bitwise representation of the source, the bits are copied exactly. (C99/C11 6.3.2.3)

  • The size of the result of subtracting two pointers to elements of the same array is the size of ptrdiff_t, which is 4 bytes. (C99/C11 6.5.6)

2.4.8. Hints (J.3.8)

  • When the optimizer is used, the register storage-class specifier is ignored. When the optimizer is not used, the compiler will preferentially place register storage class objects into registers to the extent possible. The compiler reserves the right to place any register storage class object somewhere other than a register. (C99/C11 6.7.1)

  • The inline function specifier is ignored unless the optimizer is used. For other restrictions on inlining, as well as ways to control inlining behavior, see the compiler manual. (C99/C11 6.7.4)

2.4.9. Structures, unions, enumerations, and bit-fields (J.3.9)

  • A “plain” int bit-field is treated as a signed int bit-field. (C99/C11 6.7.2, 6.7.2.1)

  • In addition to _Bool, signed int, and unsigned int, the compiler allows char, signed char, unsigned char, signed short, unsigned short, signed long, unsigned long, signed long long, unsigned long long, and enum types as bit-field types. (C99/C11 6.7.2.1)

  • Atomic types are not allowed as bit-field types

  • Bit-fields may not straddle a storage-unit boundary. (C99/C11 6.7.2.1)

  • Bit-fields are allocated in endianness order within a unit. See the compiler manual for details. (C99/C11 6.7.2.1)

  • Non-bit-field members of structures are aligned as required by the type of the member. There are user controls to override this behavior; see the compiler manual for details. (C99/C11 6.7.2.1)

  • The integer type underlying each enumerated type is described in the compiler manual. (C99/C11 6.7.2.2)

2.4.10. Qualifiers (J.3.10)

  • The compiler does not shrink or grow volatile accesses. It is the user’s responsibility to make sure the access size is appropriate for devices that only tolerate accesses of certain widths.

    • The compiler does not change the number of accesses to a volatile variable unless absolutely necessary. In some cases, the compiler will be forced to use two accesses, one for the read and one for the write, it is not guaranteed that the compiler will be able to map such expressions to an instruction with a single memory operand. It is not guaranteed that the memory system will lock that memory location for the duration of the instruction.

    • The compiler will not reorder two volatile accesses, but it may reorder a volatile and a non-volatile access, so volatile cannot be used to create a critical section. Use some sort of lock if you need to create a critical section. (C98/C11 6.7.3)

2.4.11. Preprocessing directives (J.3.11)

  • The compiler does not support pragmas that refer to headers. (C11 6.4, 6.4.7)

  • The sequences are mapped to external source file names in both forms of the #include directive (C11 6.4.7)

  • The value of a character constant in a constant expression that controls conditional inclusion matches the value of the same character constant in the execution character set (both are plain ASCII). (C99/C11 6.10.1)

  • Single-character constants in a constant expression that controls conditional inclusion have a non-negative value. (C11 6.10.1)

  • Include directives may have one of two forms, < > or ” “. For both forms, the compiler will look for a real file on-disk by that name using the “system” or “user” include file search path. See the compiler manual for details on how the system and user include file search path can be controlled with environment variables and command-line options. (C99/C11 6.4.7)

    • The compiler uses the “system” include file search path to search for an included < > delimited header file. See the compiler manual for details on how the system and user include file search path can be controlled with environment variables and command-line options. (C99/C11 6.10.2)

    • The compiler uses the “user” include file search path to search for an included ” ” delimited header file. See the compiler manual for details on how the system and user include file search path can be controlled with environment variables and command-line options. (C99/C11 6.10.2)

  • As a result of macro replacement, the sequence of tokens should be either a single string literal or a sequence of preprocessing tokens, starting with < and ending with >. Sequences of whitespace characters are replaced by a single space. (C99/C11 6.10.2)

  • There is no arbitrary nesting limit for #include processing. (C99/C11 6.10.2)

  • The # operator inserts a \ character before the \ character that begins a universal character name. (C11 6.10.3.2)

  • See the compiler manual for a description of the recognized non-standard pragmas. (C99/C11 6.10.6)

  • The date and time of translation are always available from the host. (C99 6.10.8, C11 6.10.8.1)

2.4.12. Library Functions (J.3.12)

  • Almost all of the library functions required for a hosted implementation are provided by the TI library. (C99/C11 5.1.2.1)

    • However, the following list of run-time functions and features are not implemented or fully supported:

      • fenv.h

        • Floating-point exception functions

      • inttypes.h

        • wcstoimax() / wcstoumax()

      • stdio.h

        • The %e specifier may produce “-0” when “0” is expected by the standard snprintf() does not properly pad with spaces when writing to a wide character array

      • stdlib.h

        • vfscanf() / vscanf() / vsscanf() return value on floating point matching failure is incorrect

      • wchar.h

        • fgetws() / fputws()

        • mbrlen()

        • mbsrtowcs()

        • wcscat()

        • wcschr()

        • wcscmp() / wcsncmp()

        • wcscpy() / wcsncpy()

        • wcsftime()

        • wcsrtombs()

        • wcsstr()

        • wcstok()

        • wcsxfrm()

        • Wide character print / scan functions

        • Wide character conversion functions

      • signal.h

        • signal()

        • raise()

  • The format of the diagnostic printed by the assert macro is “Assertion failed, (assertion macro argument), file file, line line”. (C99/C11 7.2.1.1)

  • The feraiseexcept function is not supported. (C11 7.6.2.3)

  • No strings other than “C” and “” may be passed as the second argument to the setlocale function (C99/C11 7.11.1.1)

  • The types defined for float_t and double_t when the value of the FLT_EVAL_METHOD macro is less than 0 or greater than 2 are float and double, respectively. (C99/C11 7.12)

  • On underflow range errors, the mathematics functions return 0.0 and the errno is set to ERANGE. Floating-point exceptions raised using the feraiseexcept function are not supported. (C99/C11 7.12.1)

  • The base-2 logarithm of the modulus used by the remquo functions in reducing the quotient is 31. The last 31bits of the quotient are returned (values up to 2^{31}). (C99/C11 7.12.10.3)

  • No signal handling is supported. (C99/C11 7.14.1.1)

  • The +INF, -INF, +inf, -inf, NAN, and nan styles can be used to print an infinity or NaN. (C99 7.19.6.1, 7.24.2.1; C11 7.21.6.1, 7.29.2.1)

  • The output for %p conversion in the fprintf or fwprintf function is the same as %x of the appropriate size. (C99 7.19.6.1, 7.24.2.1; C11 7.21.6.1, 7.29.2.1)

  • Any n-char or n-wchar sequence in a string, representing a NaN, that is converted by the strtod, strtof, or strtold functions, is ignored. The wcstod, wcstof, and wcstold functions are not supported. (C99 7.20.1.3, 7.24.4.1.1; C11 7.22.1.3, 7.29.4.1.1)

  • The strtod, strtof, or strtold functions set errno to ERANGE when underflow occurs. The wcstod, wcstof, and wcstold functions are not supported. (C99 7.20.1.3, 7.24.4.1.1; C11 7.22.1.3, 7.29.4.1.1)

  • Open streams with unwritten buffered data are flushed, open streams are closed, and temporary files are removed when the _Exit function is called. The function abort does not close or flush open streams nor does it remove temporary files when it is called. (C99 7.20.4.1, 7.20.4.4, C11 7.22.4.1, 7.22.4.5)

  • The termination status returned to the host environment by the abort, exit, _Exit, or quickexit function is not returned to the host environment. (C99 7.20.4.1, 7.20.4.3, 7.20.4.4, C11 7.22.4.1, 7.22.4.4, 7.22.4.5, 7.22.4.7)

  • The system function is not supported. (C99 7.20.4.6, C11 7.22.4.8)

2.4.13. Architecture (J.3.13)

  • The values or expressions assigned to the macros specified in the headers float.h, limits.h, and stdint.h are described along with the sizes and format of integer types in the compiler manual. (C99 5.2.4.2, 7.18.2, 7.18.3; C11 5.2.4.2, 7.20.2, 7.20.3)

  • Thread storage is not supported. (C11 6.2.4)

  • The number, order, and encoding of bytes in any object are described in the compiler manual. (C99/C11 6.2.6.1)

  • Valid alignments as well as extended alignments up to 2^{28} bytes are supported. (C11 6.2.8)

  • The value of the result of the sizeof and _Alignof operators is the storage size for each type, in terms of bytes. See the compiler manual (C99/C11 6.5.3.4)

2.4.14. Locale-specific behavior (J.4)

  • The behavior of these points is dependent on the implementation of the C library. The compiler currently supports only one locale, “C”.