This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/33901] New: assumes target of a const pointer is read-only


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]