From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15151 invoked by alias); 27 Feb 2005 22:30:47 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 14887 invoked by alias); 27 Feb 2005 22:30:37 -0000 Date: Mon, 28 Feb 2005 10:00:00 -0000 Message-ID: <20050227223037.14886.qmail@sourceware.org> From: "joseph at codesourcery dot com" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050227052446.20230.kmk@ssl.org> References: <20050227052446.20230.kmk@ssl.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/20230] GCC generates non-compliant warnings for qualifier promotion X-Bugzilla-Reason: CC X-SW-Source: 2005-02/txt/msg03382.txt.bz2 List-Id: ------- Additional Comments From joseph at codesourcery dot com 2005-02-27 22:30 ------- Subject: Re: GCC generates non-compliant warnings for qualifier promotion On Sun, 27 Feb 2005, kmk at ssl dot org wrote: > 1. A pointer is a derived type. > > 2. A derived type is not qualified by the qualifiers (if any) of the type from > which it is derived. > > 3. For any qualifier q, a POINTER to a non-q-qualified type may be converted to > a pointer to the q-qualified version of the type. [emphasis mine; note that a > pointer is, by itself, a derived type which does not inherit any qualifiers---so > what] Indeed, a pointer to non-qualified "char *" may be converted to a pointer to qualified "char *". For example, "char **" or "char **const" may be converted to "char *const *" or "char *volatile *const restrict". But "const char *" isn't a qualified version of "char *"; "char *" and "const char *" are entirely distinct unqualified types. So "char **" may not be converted to "const char *const *", because they are pointers to distinct unqualified types, not pointers to qualified and unqualified versions of the same type. Your misconception appears to be that "const char *" is a qualified version of "char *". It isn't. They are incompatible unqualified types. Similarly, "const char *const *" is not a qualified version of "char **". > 4. A pointer to a pointer is itself a pointer. > > 5. The C standard, unlike C++, does not further restrict qualifier promotion of > multi-level pointers---in fact, it is completely silent on the issue. It doesn't need to discuss the issue, as it follows from the definitions in the standard. There is *no* concept of multi-level pointers in the standard; just that of pointers, derived from a type which may or may not be a pointer. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20230