https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120358
--- Comment #27 from Holger Hoffstätte <hol...@applied-asynchrony.com> --- If I add lifetime-extending printfs to QStringTokenizerBase::next() like this: --- qstringtokenizer.h 2025-07-04 17:56:28.523676630 +0200 +++ qstringtokenizer-printf.h 2025-07-04 17:56:03.998840901 +0200 @@ -389,11 +389,14 @@ auto QStringTokenizerBase<Haystack, Need const auto ns = QtPrivate::Tok::tokenSize(m_needle); state.start = state.end + ns; state.extra = (ns == 0 ? 1 : 0); + __builtin_printf("\nsliced: '%s'\n", result.toString().toStdString().c_str()); } else { // token separator not found => return final element: result = m_haystack.sliced(state.start); + __builtin_printf("\nfinal: '%s'\n", result.toString().toStdString().c_str()); } if ((m_sb & Qt::SkipEmptyParts) && result.isEmpty()) { + __builtin_printf("\nskipping empty result: '%s'\n", result.toString().toStdString().c_str()); continue; } return {result, true, state}; ..it starts to work. Removing any one of these printfs breaks the lifetime of the intermediate "Haystack result" and leads to garbage when trying to find the last element.