samedi 4 juillet 2015

Uniform Initializing vector of strings causes address sanitizer error

Previously I had code that would create a vector of strings and add one element via:

std::vector<std::string> attempt_one;
attempt_one.emplace_back( "Hello, world!" );

This code compiles and works as expect. If I attempt to instead create the vector of strings as

std::vector<std::string> attempt_two{ "Hello, world!" };

the code compiles fine, but when compiled with the address sanitizer enabled, the code fails at run time with the error:

Sanitizer CHECK failed: /...long_path.../asan_mapping.h:179 ((AddrIsInMem(p))) != (0) (0, 0)

What is the bug in my second attempt at creating the vector that is causing this error? For reference this is Clang 3.7 with the -std=c++11 and address sanitizer enabled.

Aucun commentaire:

Enregistrer un commentaire