This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/33901] New: assumes target of a const pointer is read-only
- From: "rmh at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 Oct 2007 20:17:30 -0000
- Subject: [Bug c/33901] New: assumes target of a const pointer is read-only
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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 ‘main’:
<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