Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Newsgroups | comp.lang.c |
|---|---|
| From | Heikki Kallasjoki <see@end.of.message.invalid> |
| Subject | Re: Rationale for Some of 6.7.3p9? |
| References | (3 earlier) <iqr9ck$t76$1@usenet01.boi.hp.com> <lnr57yfz42.fsf@nuthaus.mib.org> <0.61635c98e980b76d7f74.20110516230009BST.87tycuux06.fsf@bsb.me.uk> <iqsqmq$63s$1@dont-email.me> <iqsqsj$63s$2@dont-email.me> |
| Organization | nonexistent |
| Message-ID | <slrnit441a.15l.fis@iris.zem.fi> (permalink) |
| Date | 2011-05-17 06:06 +0000 |
On 2011-05-17, Shao Miller <sha0.miller@gmail.com> wrote:
>> Speaking of which, does anyone have any clue as to the rationale behind
>> why, in:
>>
>> int main(void) {
>> char c = 'C';
>> char * cp = &c;
>> const char * ccp = &c;
>> char ** cpp = &cp;
>> #ifdef NOPE
>> const char ** ccpp = &cp;
>> #endif
>> const char ** ccpp = &ccp;
>>
>> return 0;
>> }
>>
>> we are not permitted to (in a standard sense) "suddenly" 'const'-qualify
>> the doubly-pointed-to type? It would appear that 6.7.3p9 prevents us
>> from having compatible types there, and I could understand not wanting
>> to allow for the _removal_ of 'const' qualification, but couldn't it be
>> helpful to add it?
If the conversion from "char **" to "const char **" were allowed without
a cast, the following would be legal:
const char c = 'A';
char *cp = NULL;
const char **ccpp = &cp; /* (1) */
*ccpp = &c; /* (2) */
*cp = 'B'; /* (3) */
Here line (1) converts a char ** to const char ** and normally requires a
cast. Line (2) is legal (ccpp is const char **, so *cpp is const char *,
and that can be set to point to a "const char" without problems.
Unfortunately that has set our char *cp to point to a const char without
casts, and line (3) then silently modifies a const object.
Converting char ** to const char * const* shouls be safe, though.
(Disclaimer: just a gut feeling.)
--
Heikki Kallasjoki
email: echo 'zfs+es_t_i@n_u.zf' | tr zen_muftis fuze_mints
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
I need help janus <emekamicro@gmail.com> - 2011-05-14 04:05 -0700
Re: I need help "Heinrich Wolf" <invalid@invalid.invalid> - 2011-05-14 13:30 +0200
Re: I need help "Joachim Schmitz" <jojo.nospam@schmitz-digital.de> - 2011-05-14 13:46 +0200
Re: I need help "Heinrich Wolf" <invalid@invalid.invalid> - 2011-05-14 14:20 +0200
Re: I need help Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-14 04:48 -0700
Re: I need help "Joachim Schmitz" <jojo.nospam@schmitz-digital.de> - 2011-05-14 13:39 +0200
Re: I need help "Joachim Schmitz" <jojo.nospam@schmitz-digital.de> - 2011-05-14 13:44 +0200
Re: I need help "Heinrich Wolf" <invalid@invalid.invalid> - 2011-05-14 14:23 +0200
Re: I need help "Joachim Schmitz" <jojo.nospam@schmitz-digital.de> - 2011-05-16 16:47 +0200
Re: I need help James Kuyper <jameskuyper@verizon.net> - 2011-05-14 09:14 -0400
Re: I need help "Joachim Schmitz" <jojo.nospam@schmitz-digital.de> - 2011-05-16 16:43 +0200
Re: I need help Keith Thompson <kst-u@mib.org> - 2011-05-16 08:23 -0700
Re: I need help Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-16 23:00 +0100
Rationale for Shao Miller <sha0.miller@gmail.com> - 2011-05-16 23:40 -0500
Re: Rationale for Some of 6.7.3p9? Shao Miller <sha0.miller@gmail.com> - 2011-05-16 23:43 -0500
Re: Rationale for Some of 6.7.3p9? Heikki Kallasjoki <see@end.of.message.invalid> - 2011-05-17 06:06 +0000
Re: Rationale for Some of 6.7.3p9? Heikki Kallasjoki <see@end.of.message.invalid> - 2011-05-17 06:13 +0000
Re: Rationale for Some of 6.7.3p9? Angel <angel+news@spamcop.net> - 2011-05-17 14:03 +0000
Re: Rationale for Some of 6.7.3p9? Shao Miller <sha0.miller@gmail.com> - 2011-05-17 10:19 -0400
Re: Rationale for Ike Naar <ike@iceland.freeshell.org> - 2011-05-17 06:09 +0000
Re: Rationale for Shao Miller <sha0.miller@gmail.com> - 2011-05-17 10:20 -0400
Re: I need help Columbus sailed the ocean China Blue <chine.bleu@yahoo.com> - 2011-05-14 04:45 -0700
Re: I need help Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-14 09:39 -0400
Re: I need help sandeep <nospam@nospam.com> - 2011-05-15 21:37 +0000
Re: I need help Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-05-15 18:35 -0400
Re: I need help pete <pfiland@mindspring.com> - 2011-05-15 19:45 -0400
Re: I need help pete <pfiland@mindspring.com> - 2011-05-15 20:15 -0400
Re: I need help sandeep <nospam@nospam.com> - 2011-05-16 18:27 +0000
Re: I need help Shao Miller <sha0.miller@gmail.com> - 2011-05-16 14:45 -0400
Re: I need help Keith Thompson <kst-u@mib.org> - 2011-05-16 11:41 -0700
Re: I need help Seebs <usenet-nospam@seebs.net> - 2011-05-16 19:12 +0000
Re: I need help Keith Thompson <kst-u@mib.org> - 2011-05-16 12:30 -0700
Re: I need help Seebs <usenet-nospam@seebs.net> - 2011-05-16 20:09 +0000
Re: I need help sandeep <nospam@nospam.com> - 2011-05-16 20:35 +0000
Re: I need help Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-16 23:22 +0100
Re: I need help David Thompson <dave.thompson2@verizon.net> - 2011-05-24 01:19 -0400
Re: I need help Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-19 00:19 -0700
Re: I need help Seebs <usenet-nospam@seebs.net> - 2011-05-19 14:37 +0000
Re: I need help Keith Thompson <kst-u@mib.org> - 2011-05-19 08:17 -0700
Re: I need help Seebs <usenet-nospam@seebs.net> - 2011-05-19 16:08 +0000
Re: I need help Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-19 11:13 -0700
Re: I need help Keith Thompson <kst-u@mib.org> - 2011-05-16 08:12 -0700
csiph-web