Article View: comp.std.c
Article #32Re: Questions about conversions of pointer-to-qualified types.
From: Larry Jones
Date: Thu, 29 Oct 1992 16:41
Date: Thu, 29 Oct 1992 16:41
42 lines
2472 bytes
2472 bytes
In article <1992Oct28.183839.7639@netcom.com>, rfg@netcom.com (Ronald F. Guilmette) writes: > If I understand you correctly, you are saying that all of section 3.2 (and > its subsections) describe (in general terms) *possible* implicit conversions, > but the *actual* conversions which may be applied in any given context will > depend upon the operator being used (which, in the case of my question, was > the `=' operator). 3.2 describes most possible conversions (3.3.4 Cast Operators specifies some additional "unusual" conversions), it doesn't say anything about whether they are implicit or explicit. Some operators specify that some conversions happen implicitly, the cast operator applies an explicit conversion. > Specifically, consider: > const char *ccp; > const void *cvp; > cvp = ccp; > Now if I understood you, you are saying that this should be allowed because > the description of the operator `=' says (in effect) that it is OK to > assign a value of type pointer-to-T1 (where T1 is some qualified or > unqualified object type) to an lvalue which has type pointer-to-T2, where > `T2' is a (possibly qualified) void type which has *at least* the same > qualifiers as type T1 has. Yes? Yes. > That all seems reasonable, but *only* as long as we read *only* 3.3.16.1 > and *ignore* the verbage in 3.2.2.3 (which does *not* give *any* permission > for a value of type pointer-to-qualified-object to be implicitly converted > to a pointer-to-qualified-void. I read the first paragraph of 3.2.2.3 as applying reguardless of qualifiers -- a const qualified pointer to void is still a pointer to void and thus may be converted to or from any object type, with no effect on the qualifiers. The second paragraph of 3.2.2.3 then specifies what can be done with the qualifiers, independent of the underlying type. ---- Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH 45150-2789 513-576-2070 larry.jones@sdrc.com or ...uunet!sdrc!larry.jones I stand FIRM in my belief of what's right! I REFUSE to compromise my principles! -- Calvin
Technical Details
Message-ID:
<2187@sdrc.COM>Path:
arc1-ca.pugleaf.net!sparky!uunet!sdrc!thor!scjonesReferences:
<1992Oct27.073329.6679@netcom.com> <2173@sdrc.COM> <1992Oct28.183839.7639@netcom.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!sdrc!thor!scjones From: scjones@thor.sdrc.com (Larry Jones) Newsgroups: comp.std.c Subject: Re: Questions about conversions of pointer-to-qualified types. Message-ID: <2187@sdrc.COM> Date: 29 Oct 92 16:41:20 GMT References: <1992Oct27.073329.6679@netcom.com> <2173@sdrc.COM> <1992Oct28.183839.7639@netcom.com> Sender: news@sdrc.COM Lines: 42