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

            Bug ID: 99779
           Summary: [GCC-10.1.0]A bug when assign to a pointer by function
                    which process the pointer inside.
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xin....@compiler-dev.com
  Target Milestone: ---

As shown in the following testcase:

int helloa = 12;
int hellob = 13;
int *fp=&helloa;
int __attribute__((noinline)) foo()
{
  fp=&hellob;
  return 15;
}
int main()
{
  *fp = foo();
  printf("helloa=%d,hellob=%d\n",helloa,hellob);
}

compile with gcc-10.1.0 and any optimization, the result is

    helloa=15,hellob=13

but with clang-10.0.1, the result is

    helloa=12,hellob=15

According to this testcase, in my opinion ,the clang's result is right.
gcc do not process it correctly.

Reply via email to