Safe mode compiles C and C++ programs with AddressSanitizer and UndefinedBehaviorSanitizer on the CodeLab runner, catching out-of-bounds array access, null pointers, use-after-free and integer overflow with the exact line highlighted.

#include <stdio.h>

int main(void)
{
    int a[3] = {10, 20, 30};
    int sum = 0;
    for (int i = 0; i <= 3; i++) { /* bug: i <= 3 reads a[3] */
        sum += a[i];
    }
    printf("sum = %d\n", sum);
    return 0;
}

Student
  1. First click Run normally: the bug may silently print garbage. Then tick Safe mode in the toolbar and click Run again: the out-of-bounds read on line 8 is caught and highlighted.
Teacher
  1. Every runnable C and C++ example has the Safe mode toggle automatically when the CodeLab runner is configured.