Open
Description
https://cppcoach.godbolt.org/z/34TPh8vPh
#include <vector>
char example(const std::vector<char> v)
{
return v[2];
}
int main()
{
std::vector<char> values;
values.resize(10);
values.resize(1);
example(values);
}
observations:
- gcc14 catches this case with
-fsanitize=address,undefined
at all levels (just as an aside) - gcc14 misses this case with just
-fsanitize=address
at all levels above -O0 (just as an aside) - clang18 catches this case with
-fsanitize=address
at -O0 - clang18 misses this case with
-fsanitize=address
at -O1 or higher, and adding-fsanitize=address,undefined
makes no difference.