

In order to check your program with ubsan, compile and link the program with -fsanitize=undefined option. GCC recently (version 4.9) gained Undefined Behavior Sanitizer (ubsan), a run-time checker for the C and C++ languages. Often this is not the case and the checking has to take place at run time. The compiler can issue a warning at compile time, but only in case it can statically detect some kind of wrongdoing.

Luckily, there are ways to detect at least some of the undefined behavior in a program. The application can produce wrong results, crash, or print the complete text of Proust's oeuvre. For instance, using non-static variable before it has been initialized is undefined. If an undefined behavior occurs, the compiler is free to do anything. Notwithstanding that, bugs cost software companies a lot of money every year and upset customers, users, and developers. Some bugs happen as a result of undefined behavior occurring in the program. Undefined behavior is a concept known especially in the C and C++ languages which means that the semantics of certain operations is undefined and the compiler presumes that such operations never happen. Not every software bug has as serious consequences as seen in the Ariane 5 rocket crash.
ARIANE 5 INTEGER OVERFLOW INSTALL
(See this article to install GCC 7 on Red Hat Enterprise Linux via yum.)
