Given the following code:

main ()
{
  const char *foo = 0;
  *foo = 0;
}

gcc will refuse to compile it with:

$ echo "main () { const char *foo = 0; *foo = 0; }" | gcc -x c -c - -o
/dev/null
<stdin>: In function &#8216;main&#8217;:
<stdin>:1: error: assignment of read-only location

Sure, foo is read-only, but *foo is just a memory location; one should be able
to write to it.


-- 
           Summary: assumes target of a const pointer is read-only
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rmh at gcc dot gnu dot org


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

Reply via email to