strlen example, source code: #include <string.h> int main() { return strlen("Hello world!"); } strlen example, assembly code at -O3: movl $12, %eax ret wcslen example, source code: #include <wchar.h> int main() { return wcslen(L"Hello world!"); } wcslen example, assembly code at -O3: subq $8, %rsp .cfi_def_cfa_offset 16 leaq .LC0(%rip), %rdi call wcslen@PLT addq $8, %rsp .cfi_def_cfa_offset 8 ret Interestingly, Clang produces identical assembly code for both examples, which is what I expected GCC to do.
GCC does not optimize any of the wide character functions ...
Thus confirmed.