Strange behavior when add stringref

My code in my project looks like this
图片
ka_attr::MEM_DDR and memTypeStr are both StringRef. When I build my project in release build type using cmake, the result is
图片 which is not I want.
When I build project in DEBUG build type, the result is
图片
I want to know why the result is different between release and debug type?

Probably invoking UB due to the string concatenation producing a Twine, which is only good as a temporary. If you remove the use of auto that’ll be more obvious, probably.

https://llvm.org/docs/ProgrammersManual.html#the-twine-class

There’s a lint warning for using Twine values as temporaries if you’re using clangd I believe. I’d recommend using typeStr = (...).str() instead.