2.5. Characteristics and Implementation of Arm C++

The tiarmclang compiler supports C++ as defined in the ANSI/ISO/IEC 14882:2017 standard (C++17), including these features:

  • Complete C++ standard library support, with exceptions noted below.

  • C++ Templates

  • Exception handling, which can be enabled with the -fexceptions compiler option (see C++ Exception Handling)

  • Run-time type information (RTTI), which can be enabled with the -frtti compiler option.

The following features are not implemented or fully supported:

  • Features related to threads and concurrency, such as:

    • std::thread

    • std::unique_lock

    • std::shared_mutex

    • std::execution

    • C++ atomic operations

    • thread-local storage

  • Some features related to memory management, such as:

    • std::pmr::memory_resource

    • std::align_val_t

  • The Filesystem library

  • The C++17 Mathematical Special Functions library

Please see C++ Language Variants (-std) for supported C++ language variants as well as the options that control the language standard used.

2.5.1. C++ Exception Handling

The tiarmclang compiler now supports the C++ exception handling features defined by the ANSI/ISO 14882 C++ Standard. See The C++ Programming Language, Third Edition by Bjarne Stroustrup.

(The C library provides no built-in support for C exception handling.)

To enable C++ exception handling, use the compiler’s -fexceptions option. By default, the compiler provides no exception handling support; this is the equivalent of using the -fno-exceptions option.

For exceptions to work correctly, the following must be true:

  • All C++ files in the application must have been compiled with the -fexceptions option, regardless of whether exceptions occur in that file. Mixing exception-enabled and exception disabled object files and libraries can lead to undefined behavior.

  • You must link an application with a run-time-support library that contains exception handling support. The run-time-support libraries provided with the tiarmclang compiler come in both exception-enabled and exception-disabled forms. When you use automatic library selection (the default), the linker automatically selects the correct library. If you specify the library manually, you must use a version in a sub-directory called except of the usual directory for your target. See Library Naming Conventions.

  • The -fno-rtti option must not be used to compile any C++ files in the application.

Using the -fexceptions option causes the compiler to insert exception handling code. This inserted code increases the size of the program, but not by a large amount. Compiling for exception support also slightly increases the data size to accommodate the exception handling tables. Compiling for exception support has a minimal execution time cost if exceptions are never thrown.

To optimize the size of exception-handling tables, the nothrow attribute may be applied to a function to inform the compiler that the function cannot throw an exception. See nothrow for details.

For details about C++ exception handling and the Arm ABI, see the Application Binary Interface for the Arm Architecture documentation. For device-specific details, see the Arm Developer information; for example, exception handling documentation for ARMv8-M is available here.

See C Exception Handler Calling Convention for information about C language exception handling.