lihuang added a comment. We only do this optimization when s is a string literal, so that strlen(s) could be computed at compile time. The motivation is, this could save some function calls, and gcc has this optimization. http://reviews.llvm.org/D18230