3 ms·
Wait this code can't work - as you holding only a string_view in the Symbol... // __start_ and __stop_ symbols for (OutputChunk *chunk : chunks) { if (
by malkia 6y ago
Wait this code can't work - as you holding only a string_view in the Symbol...
// __start_ and __stop_ symbols
for (OutputChunk *chunk : chunks) {
if (is_c_identifier(chunk->name)) {
start(Symbol::intern("__start_" + std::string(chunk->name)), chunk);
stop(Symbol::intern("__stop_" + std::string(chunk->name)), chunk);
}
}
- malkia 6y agoOr this: for (std::string_view arg : config.version_script) parse_version_script(std::string(arg));
- malkia 6y agoAlthough if somehow nothing gets really freed, and std::string() is kept intact after calling the destructor (e.g. it's data() is still valid) then it'll work :)
- ArchOversight 6y ago`parse_version_script` is defined as taking an `std::string`, std::string() over an `std::string_view` will create a new std::string with a copy of the data from arg.
- deleted 6y ago[deleted]
- ArchOversight 6y agoThis does seem broken, since the temporary string that is created by the concatenation is short lived, and the std::string_view inside the Symbol won't hold on to it, just the pointer to the data.
- rui314 6y agoAh, that's a bug. Thank you for finding it!