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

           Summary: strcpy returns unexpected result
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: jachrist...@gmail.com


This is my first bug report, I am not sure I have assigned the correct
category to this and whether this is actually a bug or change in philosophy.

My code was last compiled on GCC 4.1.2 and many other previous versions of 
the GCC compilers over the last 8 years.
Are moving to a 64bit machine and this code that has worked for years, now
gives a strange result.

gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)


A test case is as follows , built with gcc -osample sample.c

#include <stdio.h>
#include <string.h>


int main(int argc, char *argv[])
{

      char data[20];


      strcpy(data, "2010-1004");
      strcpy(&data[4], &data[5]);
      printf("%s\n", data);
      return 0;

}


The expected return in data is "20101004", GCC 4.4.3 is returning "20101044"

I have no explanation for the unexpected result.

Thanks,
   John

Reply via email to