Function pointer casts in ANSI C

Lars Henrik Mathiesen thorinn at rimfaxe.diku.dk
Wed Dec 5 00:52:29 AEST 1990


thorinn at skinfaxe.diku.dk (Lars Henrik Mathiesen) writes:
>My question is: Can a conforming compiler generate a warning for casts
>(and arguments) that will ``go wrong'' but not for those that work?

gwyn at smoke.brl.mil (Doug Gwyn) writes:
>A conforming implementation must produce at least one diagnostic for each
>translation unit that violates a syntax rule or constraint.  Diagnostics
>may be produced under other circumstances, but are not required.

Doug's analysis applies to the "(and arguments)" in the question. For
casts, 3.3.4 (Cast operators) Semantics tells us that behaviour is
undefined because the function types are incompatible, but no
diagnostic is required.

manning at nntp-server.caltech.edu (Evan Marshall Manning) writes:
>My favorite lint (from Gimpel) would call those that work "non-portable",
>and issue a more serious warning/error message for those that not will
>work.

Is this lint architecture- and compiler-specific (or configurable)
since it knows what works? Or does it just guess based on two's
complement, byte addressable, 32-bit int and pointer machines?

--
Lars Mathiesen, DIKU, U of Copenhagen, Denmark      [uunet!]mcsun!diku!thorinn
Institute of Datalogy -- we're scientists, not engineers.      thorinn at diku.dk



More information about the Comp.lang.c mailing list