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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Function arguments and return values don't modify existing objects, the copies
are new objects. In the assignment in your code you modify an existing object.
If it was allowed what would prevent you from doing:

  struct A a = { 1, 2 }
  struct A *ptr = &a;
  *ptr = (struct A) {10, 10};

Or simply:

  struct A *ptr = malloc(sizeof(struct A));
  *ptr = (struct A) {10, 10};
  *ptr = (struct A) {11, 11};

(Clang allows both of these, despite the fact they modify a const object).

Reply via email to