https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101443
--- Comment #2 from Rafi Wiener <rawiener at amazon dot com> --- Hey I just found that if I wrap the lines template<typename T> struct pchar2string { static T cast(T& t) {return t;} }; with those pragma to disable optimization it works. #pragma GCC push_options #pragma GCC optimize ("O0") #pragma GCC pop_options