https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77717
Bug ID: 77717 Summary: testsuite/21_strings/basic_string_view/operations/comp are/char/1.cc makes undefined memcmp call Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: acsawdey at gcc dot gnu.org CC: ville.voutilainen at gmail dot com Target Milestone: --- This test case makes an undefined call to memcmp because the string constant is shorter than the length given. "costa rica" is 11 bytes including the '\0' but length of 14 is given. The last two lines of code quoted below both do it. int test01() { using std::string_view; string_view str_0("costa rica"); string_view str_1("costa marbella"); string_view str_2; //sanity check test_value(strcmp("costa marbella", "costa rica"), lt); test_value(strcmp("costa rica", "costa rica"), z); test_value(strcmp(str_1.data(), str_0.data()), lt); test_value(strcmp(str_0.data(), str_1.data()), gt); test_value(strncmp(str_1.data(), str_0.data(), 6), z); test_value(strncmp(str_1.data(), str_0.data(), 14), lt); test_value(memcmp(str_1.data(), str_0.data(), 6), z); test_value(memcmp(str_1.data(), str_0.data(), 14), lt); test_value(memcmp("costa marbella", "costa rica", 14), lt);