improve c++-11 compliance. replace variable size stack allocation.
(cherry picked from commit af224028a925cba90d818742ab210f3d5b414611)