aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2023-01-13 21:15:44 -0300
committerAlexandre Oliva <oliva@gnu.org>2023-01-13 21:15:44 -0300
commit88679960c2665d87c8354ce35a48aaadbe3f0793 (patch)
tree363067a301e087ea439e9e04a8120799877da304 /gcc/c-family
parent31aaa6ef5a952d4f64fb04010459f28e0e793702 (diff)
downloadgcc-88679960c2665d87c8354ce35a48aaadbe3f0793.zip
gcc-88679960c2665d87c8354ce35a48aaadbe3f0793.tar.gz
gcc-88679960c2665d87c8354ce35a48aaadbe3f0793.tar.bz2
hash table: enforce testing is_empty before is_deleted
Existing hash_table traits that use the same representation for empty and deleted slots reject marking slots as deleted, and to not pass is_deleted for slots that pass is_empty. Nevertheless, nearly everywhere, we only test for is_deleted after checking that !is_empty first. The one exception was the copy constructor, that would fail if traits recognized is_empty slots as is_deleted, but then refused to mark_deleted. This asymmetry is neither necessary nor desirable, and there is a theoretical risk that traits might not only fail to refuse to mark_deleted, but also return is_deleted for is_empty slots. This patch introduces checks that detect these potentially problematic situations, and reorders the tests in the copy constructor so as to use the conventional testing order and thus avoid them. for gcc/ChangeLog * hash-table.h (is_deleted): Precheck !is_empty. (mark_deleted): Postcheck !is_empty. (copy constructor): Test is_empty before is_deleted.
Diffstat (limited to 'gcc/c-family')
0 files changed, 0 insertions, 0 deletions