Skip to Content.
Sympa Menu

c-semantics - [C-Semantics] possibly redundant undefinedness in function calls

c-semantics AT lists.cs.illinois.edu

Subject: C Semantics in K Framework

List archive

[C-Semantics] possibly redundant undefinedness in function calls


Chronological Thread 
  • From: Chucky Ellison <celliso2 AT illinois.edu>
  • To: c-semantics AT cs.illinois.edu
  • Subject: [C-Semantics] possibly redundant undefinedness in function calls
  • Date: Tue, 7 Feb 2012 15:26:36 -0600
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/c-semantics>
  • List-id: C Semantics in K Framework <c-semantics.cs.illinois.edu>

In the semantics of function calls section, the standard (n1570)
6.5.2.2:9 says, "If the function is defined with a type that is not
compatible with the type (of the expression) pointed to by the
expression that denotes the called function, the behavior is
undefined."

I'm having some difficulty understanding this passage. I'm finding it
quite hard to parse (e.g., how can an expression point to a type or
expression?), but it seems to say that if I try to call a function,
the type of the calling expression needs to be compatible with the
type of the actual function.

http://c0x.coding-guidelines.com/6.5.2.2.pdf suggests that "For this
situation to occur either a pointer-to function type has to be
explicitly cast to an incompatible pointer to function type, or the
declaration visible at the point of call is not compatible with the
function definition it
refers to.

If there is a casting, I don't understand how this is any different
than 6.3.2.3:8, which says, "If a converted pointer is used to call a
function whose type is not compatible with the referenced type, the
behavior is undefined." If the visible declaration is not compatible
with the function definition, I don't understand why 6.2.7:2 wouldn't
apply, "All declarations that refer to the same object or function
shall have compatible type; otherwise, the behavior is undefined."

Does anyone have any idea how 6.5.2.2:9 is any different than the
above cases? Ideally, via a program that is undefined only because of
6.5.2.2:9 and not 6.3.2.3:8 or 6.2.7:2. Otherwise, 6.5.2.2:9 is
redundant (and imho, poorly worded).

-Chucky




Archive powered by MHonArc 2.6.16.

Top of Page