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

            Bug ID: 69480
           Summary: Bad error message on assigning to read-only
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: segher at gcc dot gnu.org
                CC: hector at marcansoft dot com
  Target Milestone: ---

This testcase from Hector

====
#include <stdint.h>

struct fail {
        uint32_t *p;
};

#define __ACCESS_ONCE(x) ({ \
         typeof(x) __var = ( typeof(x)) 0; \
                         (volatile const typeof(x) *)&(x); })
#define ACCESS_ONCE(x) (*__ACCESS_ONCE(x))

void fail(struct fail *s, uint32_t p) {
        ACCESS_ONCE(*s->p) = p;
}
====

results in

fail.c: In function 'fail':
fail.c:13:21: error: assignment of read-only location
'*__builtin_memcpy(&<U1950>, &({...}))'
  ACCESS_ONCE(*s->p) = p;
                     ^

There is no __builtin_memcpy in the program source, but the <U1950> is
even more worrying (the number is different on different runs).

Reply via email to