Fix dangling reference error on gcc