You must log in or # to comment.
GCC’s sanitizers actually catches most of these. The only one it wont complain about is
#include <optional> int f() { std::optional<int> x(std::nullopt); return *x; }
because
nullopt
is anullopt_t
which is akin toNULL
, and will read as0
if you try to do something with it, as far as I can tell…The
span
missing bounds checking isn’t a huge deal, but I guess it would make sense for them to add anat
method like most other containers have…TLDR: Use
g++ -Werror -Wpedantic -Wall -fsanitize=address,undefined,null
when compiling. Maybe do another run withthread
,leak
, or other sanitizers if needed.