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/16602] Spurious warnings about pointer to array -> const pointer to array conversion



------- 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


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