Compiling a program with anything from <regex> leads to -Wlarger-than warning and weirdly long compilation time.
While compiling this code
#include <regex>
int main()
{
std::regex pattern {R"(\w)"};
}
with -Wlarger-than=8192 flag I get this warning:
cc1plus: warning: size of ‘*.LASAN0’ 899648 bytes exceeds maximum object size 8192 [-Wlarger-than=]
Moreover, it takes a while to compile and the size of ‘*.LASAN0’ exceeds with greater -0 flags.
Why is this happening? Whats wrong? And is there a way to fix it?
.LASAN0is the label given to the object passed to__asan_register_globals: It is an array of structs containing information about any global variables, to be used by the AddressSanitizer.When compiled with another sanitizer (I've reproduced this with,
-fsanitize=address,undefined), the other sanitizer might employ a lot of global variables, which adds overhead to the global variable sanitizer.std::regexis known to take ages to compile. It is just a complicated class. The fact that it needs a structure with ~880KiB of data to compile with ASan and UBSan shows that.Anything of similar complexity would also have the same warning, so there's nothing wrong per se with your code. Just give a more sensible size to
-Wlarger-than(Or ignore it, it's just a warning you enabled).