The -DO_RANGE_CHECK option tells the compiler (actually the preprocessor) to compile array range checking code in the program. This option will produce code which throws Exception::Memory::Range if one tries to access an item beyond a container’s capacity.

Instead of passing this option to the compiler, one can as well insert a line reading

  #define O_RANGE_CHECK

in the source code, which will have exactly the same effect on the compiled code. However, it’s often more convenient to pass the define as compiler option, which can be put in a Makefile.

If option -DO_RANGE_CHECK is not given no range checking is done. Hence the compiled code will run faster, but can eventually produce a Segmentation fault. The use of -DO_RANGE_CHECK is recommended during the test phase of an algorithm, and most often goes in pair with the -g (build debuggable code) compiler option.

The debug version of LYRIC (libyric-g) is compiled with the -DO_RANGE_CHECK option set. This version of the library can throw an Exception::Memory::Range if it is buggy and has internal problems, which should not happen.