1.30 -ftrapv

Instructs the compiler to generate traps for signed arithmetic overflow on addition, subtraction, and multiplication operations.


Where an overflow is detected, an undefined instruction is inserted into the assembly code. In order for the overflow to get caught, an undefined instruction handler must be provided.


When both -fwrapv and -ftrapv are used in a single command, the furthest-right option overrides the other.

For example, here -ftrapv overrides -fwrapv:

armclang --target=aarch64-arm-none-eabi -fwrapv -c -ftrapv hello.c
Non-ConfidentialPDF file icon PDF versionDUI0774J
Copyright © 2014–2017, 2019 Arm Limited or its affiliates. All rights reserved.