public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "joseph at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/20230] GCC generates non-compliant warnings for qualifier promotion Date: Sun, 27 Feb 2005 18:47:00 -0000 [thread overview] Message-ID: <20050227130558.8869.qmail@sourceware.org> (raw) In-Reply-To: <20050227052446.20230.kmk@ssl.org> ------- Additional Comments From joseph at codesourcery dot com 2005-02-27 13:05 ------- Subject: Re: New: GCC generates non-compliant warnings for qualifier promotion On Sun, 27 Feb 2005, kmk at ssl dot org wrote: > "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; the values stored in the > original and converted pointers shall compare equal." [section 6.3.2.3, paragraph 2] All my references in what follows are to the standard itself, C99 as amended by TC1 and TC2. Using drafts is a false economy. > void safe_function(const char *const *s) { } > > int main(void) { > > char *mystrings[2] = { "First string", "Second string" }; > > // This call warns, but should not: > safe_function(mystrings); The constraints for function calls are not in 6.3.2.3, they are in 6.5.2.2#2, which references the constraints for assignment in 6.5.16.1#1. 6.5.16.1 Simple assignment Constraints [#1] One of the following shall hold:93) -- the left operand has qualified or unqualified arithmetic type and the right has arithmetic type; Not applicable. -- the left operand has a qualified or unqualified version of a structure or union type compatible with the type of the right; Not applicable. -- 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; The type on the left is "const char *const *". That on the right is "char **". These are pointers to "const char * const" and "char *". These types are qualified or unqualified versions of "const char *" and "char *". (Qualification is defined in 6.2.5#25: each of "char *" and "const char *" has seven qualified versions, while plain "char *" and "const char *" are both unqualified types; note the last sentence of that paragraph, "A derived type is not qualified by the qualifiers (if any) of the type from which is is derived.", and the definition of pointer types as derived types in paragraph 20.) "const char *" and "char *" are unqualified types which are not compatible: compatibility is defined in 6.2.7#1 and 6.7.3#9 says when qualified types are compatible. Note that "char" and "const char" are not compatible, because they don't have the same qualifiers, so "char *" and "const char *" are not compatible, and the unqualified version of "const char *const" is "const char *" not "char *" by the definition of qualification. -- one operand is a pointer to an object or incomplete type and the other is a pointer to a qualified or unqualified version of void, and the type pointed to by the left has all the qualifiers of the type pointed to by the right; Not applicable. -- the left operand is a pointer and the right is a null pointer constant; or Not applicable. -- the left operand has type _Bool and the right is a pointer. Not applicable. None of the above apply, so GCC diagnoses the constraint violation. If you want C++ rules, GCC provides a C++ compiler. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20230
next prev parent reply other threads:[~2005-02-27 13:06 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-02-27 16:17 [Bug debug/20230] New: " kmk at ssl dot org 2005-02-27 16:19 ` [Bug debug/20230] " pinskia at gcc dot gnu dot org 2005-02-27 16:32 ` [Bug c/20230] " pinskia at gcc dot gnu dot org 2005-02-27 16:33 ` pinskia at gcc dot gnu dot org 2005-02-27 17:14 ` kmk at ssl dot org 2005-02-27 18:16 ` falk at debian dot org 2005-02-27 18:32 ` kmk at ssl dot org 2005-02-27 18:47 ` joseph at codesourcery dot com [this message] 2005-02-27 18:57 ` falk at debian dot org 2005-02-28 6:35 ` kmk at ssl dot org 2005-02-28 8:27 ` kmk at ssl dot org 2005-02-28 10:00 ` joseph at codesourcery dot com 2005-02-28 10:27 ` kmk at ssl dot org [not found] <bug-20230-10174@http.gcc.gnu.org/bugzilla/> 2005-12-07 17:10 ` pinskia at gcc dot gnu dot org 2005-12-07 17:10 ` pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20050227130558.8869.qmail@sourceware.org \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).