This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content

GCC-Sanitizer

Determine how to correctly work with these sanitizers

Extract of the old documentation:

Memory Errors
-------------

Check if the submitted code compiles without warnings and enable AddressSanitizer, a fast memory error detector:

.. code-block:: make

    CC=gcc
    CFLAGS=-Wall -Werror -Wextra -Wpedantic -std=c11 -fsanitize=address

    ex: ex.c


Memory Leaks
------------

Check if the submitted code compiles without warnings and enable LeakSanitizer, a memory leak detector:

.. code-block:: make

    CC=gcc
    CFLAGS=-Wall -Werror -Wextra -Wpedantic -std=c11 -fsanitize=leak

    ex: ex.c

Undefined Behavior
------------------

Check if the submitted code compiles without warnings and enable UndefinedBehaviorSanitizer, a fast undefined behavior detector:

.. code-block:: make

    CC=gcc
    CFLAGS=-Wall -Werror -Wextra -Wpedantic -std=c11 -fsanitize=undefined

    ex: ex.c


.. note::

    For more information about the different sanitizers, see *3.12 Program Instrumentation Options* in ``gcc``'s documentation_

.. _documentation: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html