const in latest draft

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Jun 1 15:34:21 AEST 1989


In article <8408 at june.cs.washington.edu> pardo at 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..



More information about the Comp.std.c mailing list