Make bcache more type-safe

The bcache uses memcpy to make copies of the data passed to it.  In
C++, this is only safe for trivially-copyable types.

This patch changes bcache to require this property, and slightly
changes the API to make it easier to use when copying a single object.
It also makes the new 'insert' template methods return the correct
type.
This commit is contained in:
Tom Tromey
2024-03-20 13:24:33 -06:00
parent 56fefe83f7
commit 7149dfe819
4 changed files with 33 additions and 12 deletions

View File

@@ -4372,7 +4372,7 @@ check_types_worklist (std::vector<type_equality_entry> *worklist,
/* If the type pair has already been visited, we know it is
ok. */
cache->insert (&entry, sizeof (entry), &added);
cache->insert (entry, &added);
if (!added)
continue;