From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3542 invoked by alias); 15 Mar 2010 19:47:16 -0000 Received: (qmail 3497 invoked by uid 48); 15 Mar 2010 19:47:05 -0000 Date: Mon, 15 Mar 2010 19:47:00 -0000 Message-ID: <20100315194705.3496.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/16602] Spurious warnings about pointer to array -> const pointer to array conversion In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "ilatypov at infradead dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-03/txt/msg01422.txt.bz2 ------- 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