This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fixes basic_string operator& hijacking.
ClosedPublic

Authored by Mordante on Mar 3 2023, 10:54 AM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Commits
rG157f34af7157: [libc++] Fixes basic_string operator& hijacking.
Summary

Avoids using operator& in basic_string since an evil char-like type can
hijack this operator. Added some more evil operators, this found a place
where equality was compared directly and not via the traits.

This adds a helper test string. This is now only used in a few tests,
but the intention is to use this in more tests for basic_string.

Diff Detail

Event Timeline

Mordante created this revision.Mar 3 2023, 10:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 10:54 AM
Mordante requested review of this revision.Mar 3 2023, 10:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 10:54 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Mordante updated this revision to Diff 502199.Mar 3 2023, 11:21 AM

Adds a missing file and fixes for C++03 and C++11.

Mordante updated this revision to Diff 502659.Mar 6 2023, 8:07 AM

CI fixes.

ldionne accepted this revision.Mar 7 2023, 9:09 AM
ldionne added a subscriber: ldionne.

Nice catch -- it would be nice to improve the remaining std::string tests similarly.

libcxx/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp
23–26

Maybe?

libcxx/test/support/nasty_string.h
20–22
This revision is now accepted and ready to land.Mar 7 2023, 9:09 AM
Mordante marked 2 inline comments as done.Mar 7 2023, 10:03 AM
This revision was automatically updated to reflect the committed changes.