This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/16602] Spurious warnings about pointer to array -> const pointer to array conversion
- From: "ilatypov at infradead dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Mar 2010 19:47:05 -0000
- Subject: [Bug c/16602] Spurious warnings about pointer to array -> const pointer to array conversion
- References: <bug-16602-8968@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #10 from ilatypov at infradead dot org 2010-03-15 19:47 -------
(In reply to comment #9)
> constness of a multiply
> referenced value cannot be promised, and, therefore, C propagates the compile
> -time constness requirement up the assignment chain in cases where the level of
> pointer indirection is greater than 1.
The specs mention this case, too.
Constraints
1 One of the following shall hold:99)
[..]
- both operands are pointers to qualified or unqualified versions of
compatible types, and the type pointed to by the left has all the qualifiers of
the type pointed to by the right;
[..]
6 EXAMPLE 3 Consider the fragment:
const char **cpp;
char *p;
const char c = 'A';
cpp = &p; // constraint violation
*cpp = &c; // valid
*p = 0; // valid
The first assignment is unsafe because it would allow the following valid
code to attempt to change the value of the const object c.
from section 6.5.16.1 "Simple assignment", n1336.pdf,
http://www.open-std.org/jtc1/sc22/wg14/www/projects
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16602