Thread View: comp.std.c++
3 messages
3 total messages
Started by Quentin Barnes
Thu, 08 Oct 1992 16:26
implicit pointer of pointer argument promotion legal C++?
Author: Quentin Barnes
Date: Thu, 08 Oct 1992 16:26
Date: Thu, 08 Oct 1992 16:26
23 lines
1277 bytes
1277 bytes
In ANSI-C, the following code is not legal:
void f(const char **s);
void g()
{
char **s = 0;
f(s);
}
ANSI-C does not allow for implicit conversion of pointer of pointer
arguments. (See 3.3.2.2 for discussion of promotion of function
arguments. This case is one that does not hold true for 3.3.16.1).
Cfront 3.0.1 eats the non-ANSI-C code without blinking.
I can't find in the 23-sep-91 ANSI-C++ draft if pointer of pointer
promotion is allowed or disallowed. Can anyone point me to the
appropriate reference(s) so I know whether cfront is broken or not?
BTW, what's the latest ANSI-C++ draft?
--
Quentin Barnes
qbarnes@urbana.mcd.mot.com | ..!uiucuxc!udc!qbarnes
Re: implicit pointer of pointer argument promotion legal C++?
Author: Andrew Koenig
Date: Fri, 09 Oct 1992 04:55
Date: Fri, 09 Oct 1992 04:55
12 lines
1004 bytes
1004 bytes
In article <1992Oct8.162653.12028@urbana.mcd.mot.com> qbarnes@urbana.mcd.mot.com (Quentin Barnes) writes: > I can't find in the 23-sep-91 ANSI-C++ draft if pointer of pointer > promotion is allowed or disallowed. Can anyone point me to the > appropriate reference(s) so I know whether cfront is broken or not? Converting T** to const T** had better not be legal in C++, because if it were, it would open a hole in the type system that would allow modification of genuinely constant objects. -- --Andrew Koenig ark@europa.att.com
Re: implicit pointer of pointer argument promotion legal C++?
Author: Andrew Koenig
Date: Fri, 09 Oct 1992 14:14
Date: Fri, 09 Oct 1992 14:14
28 lines
1339 bytes
1339 bytes
In article <23842@alice.att.com>, I wrote: > Converting T** to const T** had better not be legal in C++, because if > it were, it would open a hole in the type system that would allow modification > of genuinely constant objects. I suppose I should give an example: const char x = '*'; char* p; Now, if we could make p point at x, that would be bad news because we could then change the value of x even though it is a const object. Well, if we can do this: const char** q = &p; (which is illegal, but would be legal if conversions from T** to const T** existed), then we would be able to do this: *q = &x; which would effectively make p point at x. All the other operations here are unquestionably legal, which means we must rule out the declaration of q. -- --Andrew Koenig ark@europa.att.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads