because nullopt is a nullopt_t which is akin to NULL, and will read as 0 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 an at method like most other containers have…
TLDR: Use g++ -Werror -Wpedantic -Wall -fsanitize=address,undefined,null when compiling. Maybe do another run with thread, leak, or other sanitizers if needed.
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.