We are compiling and running user submitted C++ programs in a sandbox environment with the following compile command:
g++ -std=gnu++11 -O2 -o program.exe program.cpp
However, it is possible for users to override compile flags using pragma directives. For example, the optimisation level can be overridden with this code:
#pragma GCC optimize("Ofast")
We have no control over the source code which is submitted for compilation but we need to prevent compile options from being overridden.
Is there a way to ignore pragma directives with GCC?