AK: Don't assert things about active union members in StringBase

This involves yeeting the 'invalid' union member as it was not really
checked against properly anyway; now the 'invalid' state is simply
StringData*{nullptr}, which was assumed to not exist previously.

Note that this is still accessing inactive union members, but is
promising to the compiler that they're fine where they are (the provided
debug macro AK_STRINGBASE_VERIFY_LAUNDER_DEBUG makes the
would-be-UB-if-not-for-launder ops verify that the operation is correct)

Should fix the GCC build.
This commit is contained in:
Ali Mohammad Pur 2025-03-26 17:54:30 +01:00 committed by Jelle Raaijmakers
commit a83145c751
Notes: github-actions[bot] 2025-03-27 16:05:24 +00:00
7 changed files with 96 additions and 60 deletions

View file

@ -57,19 +57,19 @@ FlyString::FlyString(String const& string)
return;
}
if (string.m_data->is_fly_string()) {
if (string.m_impl.data->is_fly_string()) {
m_data = string;
return;
}
auto it = all_fly_strings().find(string.m_data);
auto it = all_fly_strings().find(string.m_impl.data);
if (it == all_fly_strings().end()) {
m_data = string;
all_fly_strings().set(string.m_data);
string.m_data->set_fly_string(true);
all_fly_strings().set(string.m_impl.data);
string.m_impl.data->set_fly_string(true);
} else {
m_data.m_data = *it;
m_data.m_data->ref();
m_data.m_impl.data = *it;
m_data.m_impl.data->ref();
}
}