https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87823

            Bug ID: 87823
           Summary: strcpy() has bug ???
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: naka1024512256 at yahoo dot co.jp
  Target Milestone: ---

sometimes lose a byte or not collect when copying overlapping area

-------------------------------------------------------------------------
//(test.c)

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

char *p1 = "1234567890123456789012345678901234567890";
char *p2;
char buff[100];

main()
{
        test1();
}


test1()
{
        p2 = buff;
        strcpy(p2, p1);

        printf("test (%s) \n", p2);

        strcpy(p2, p2+1);

        printf("test (%s) \n", p2);
}

-------------------------------------------------------------------------
result: [ubunts 18.04 LTS] gcc 7.3.0
OS:          ubuntu 18.04 LTS
Hardware :   HP dc7900SFF  Core 2 duo E7400

test (1234567890123456789012345678901234567890) 
test (234567890123456789012345678901234567900) 

-------------------------------------------------------------------------
result: [windows XP] gcc 6.3.0
OS:          windows XP
Hardware :   HP dc7900SFF  Core 2 duo E8500

test (1234567890123456789012345678901234567890) 
test (234567890123456789012345678901234567890) 

-------------------------------------------------------------------------

Reply via email to