Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"-ftrapv" and "-fwrapv": Which is better for efficiency?

Tags:

From GNU's website:

  • -ftrapv

    This option generates traps for signed overflow on addition, subtraction, multiplication operations.

  • -fwrapv

This option instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wraps around using twos-complement representation. This flag enables some optimizations and disables others.

https://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Code-Gen-Options.html

I have two questions:

  1. Which of these options is better for performance?
  2. What what does it mean when the -ftrapv definition says it generates "traps?" Does this mean exceptions? (I'm guessing no, but it's worth asking.)

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!