Article View: comp.std.c
Article #6072Re: const in latest draft
From: Doug Gwyn
Date: Thu, 01 Jun 1989 05:34
Date: Thu, 01 Jun 1989 05:34
21 lines
1420 bytes
1420 bytes
In article <8408@june.cs.washington.edu> pardo@cs.washington.edu (David Keppel) writes:
> typedef int (*functype) (void *object);
> typedef int (*c_functype) (void const *const_object);
> c_functype f2;
> const void *object = POINTER_TO_VOID;
> void
> toplevel (functype f)
> {
> (*f)(object);
> }
> toplevel (f2); /* ERROR */
The problem is that there is a requirement that the actual pointer argument
in the function call be assignable to (an unqualified version of) the
parameter type, and the constraints on simple assignment say that the type
pointed to by the target of the assignment "has all the qualifiers of" the
type pointed to by the pointer being assigned. "All" is apparently being
interpreted as including nested inner qualifiers. I think that was actually
the intention of this clause in the Standard, as a safety to catch possible
obscure bugs in application use of qualified types. You can of course cast
the argument to the appropriate type..
Technical Details
Message-ID:
<10348@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!ames!haven!adm!smoke!gwynReferences:
<16259@gryphon.COM> <8408@june.cs.washington.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: const in latest draft Message-ID: <10348@smoke.BRL.MIL> Date: 1 Jun 89 05:34:21 GMT References: <16259@gryphon.COM> <8408@june.cs.washington.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 21