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

--- Comment #16 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to H.J. Lu from comment #15)
> This
> 
> char *
> my_bcopy(register char *from,register char *to,register I32 len) 
> {
>     char *retval = to;
> 
>     if (from - to >= 0) { 
>         while (len--)
>             *to++ = *from++;
>     }    
>     else {
>         to += len; 
>         from += len; 
>         while (len--)
>             *(--to) = *(--from);
>     }    
>     return retval;
> }
> 
> may be miscompiled.

With LTO, it is inlined.  We got len == -1:

(gdb) bt
#0  Perl_my_bcopy (len=-1, to=0xf7fd803c "\260Vx", from=<optimized out>) at
util.c:1559
#1  Perl_pp_rv2av () at pp_hot.c:474
#2  0x004e6ac6 in Perl_runops_standard () at run.c:30
#3  0x004339fc in perl_run (sv_interp=<optimized out>) at perl.c:1100
#4  0x0040348b in main (argc=9, argv=<optimized out>, env=<optimized out>)
    at unix_perlmain.c:51
(gdb) 

Should len == -1 here?

Reply via email to