http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47980

           Summary: Inefficient code for local const char arrays
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: rafael.espind...@gmail.com


gcc will compile

--------------------
void f(const char *p);

void g(void) {
  const char foo[] = "aoeuaoeuaeouaeouaoeuaoeaoxbxod";
  f(foo);
}
----------------------

to

        .cfi_startproc
        subq    $40, %rsp
        .cfi_def_cfa_offset 48
        movl    $.LC0, %esi
        movl    $31, %ecx
        leaq    1(%rsp), %rdi
        rep movsb
        leaq    1(%rsp), %rdi
        call    f
        addq    $40, %rsp
        .cfi_def_cfa_offset 8
        ret
        .cfi_endproc

No idea why it wants to copy the string before calling f.

Reply via email to