Compile time type checking in absence of a prototype

Discussion in 'C Programming' started by Sortie, Sep 2, 2009.

  1. Sortie

    Sortie Guest

    When a function call is encountered during the compile, is any
    parameter or return type checking done by the compiler?
    Sortie, Sep 2, 2009
    #1
    1. Advertising

  2. Sortie

    Eric Sosman Guest

    Sortie wrote:
    > When a function call is encountered during the compile, is any
    > parameter or return type checking done by the compiler?


    Yes.

    Next question ...?

    --
    Eric Sosman
    lid
    Eric Sosman, Sep 2, 2009
    #2
    1. Advertising

  3. Sortie

    Phil Carmody Guest

    Richard Heathfield <> writes:
    > In <Xns9C7A1576E91DDpinkisntwellgmailcom@147.102.222.230>, Sortie
    > wrote:
    >
    >> When a function call is encountered during the compile, is any
    >> parameter or return type checking done by the compiler?

    >
    > Yes.


    In the context of the subject line, "Compile time type checking
    in absence of a prototype", I'd say the answer is closer to "no".
    (But still pedantically "yes", as of course an implicit int will
    be checked against assigning it to a pointer, say, but that's not
    actually checking anything useful. I'm not sure whether you're
    taking the pedantic route or simply missed the subject line, either
    is understandable.)

    To the OP - don't assume your subject line has been read by the
    time people are reading the bodies of your posts. If there's
    essential information in it, ensure you either repeat it in
    the body, or draw clear attention to it in the body.

    Phil
    --
    If GML was an infant, SGML is the bright youngster far exceeds
    expectations and made its parents too proud, but XML is the
    drug-addicted gang member who had committed his first murder
    before he had sex, which was rape. -- Erik Naggum (1965-2009)
    Phil Carmody, Sep 2, 2009
    #3
  4. Sortie

    jacob navia Guest

    Eric Sosman a écrit :
    > Sortie wrote:
    >> When a function call is encountered during the compile, is any
    >> parameter or return type checking done by the compiler?

    >
    > Yes.
    >
    > Next question ...?
    >


    This is of course wrong, since regulars play with words here to amuse
    themselves misleading a person that asks a simple question.

    (1) No checks can be done if there is no prototype to the arguments
    being passed

    (2) The return type is "int". This means that this return type will
    be checked against assigning it to a structure or any other value
    incompatible with an integer. That trivial check allows heathfield
    and company to say "yes" (enigmatically) to demnostrate their knowledge
    and to mislead the original poster.
    jacob navia, Sep 2, 2009
    #4
  5. On 2 Sep, 09:31, jacob navia <> wrote:
    > Eric Sosman a écrit :
    >
    > > Sortie wrote:
    > >> When a function call is encountered during the compile, is any
    > >> parameter or return type checking done by the compiler?

    >
    > >     Yes.

    >
    > >     Next question ...?

    >
    > This is of course wrong, since regulars play with words here to amuse
    > themselves misleading a person that asks a simple question.
    >
    > (1) No checks can be done if there is no prototype to the arguments
    > being passed
    >
    > (2) The return type is "int". This means that this return type will
    > be checked against assigning it to a structure or any other value
    > incompatible with an integer. That trivial check allows heathfield
    > and company to say "yes" (enigmatically) to demnostrate their knowledge
    > and to mislead the original poster.


    seems like a pretty standard usage of the word "yes".
    The OP said "is *any* parameter or return type checing done?".
    And the answert is "yes, some is done". People also explained why the
    simple answer wasn't all that useful.
    Nick Keighley, Sep 2, 2009
    #5
  6. Sortie

    Sortie Guest

    jacob navia <> wrote in
    news:h7lagd$bu4$:

    > Eric Sosman a crit :


    <snip>

    Thanks.
    Sortie, Sep 2, 2009
    #6
  7. Sortie

    Eric Sosman Guest

    jacob navia wrote:
    > Eric Sosman a écrit :
    >> Sortie wrote:
    >>> When a function call is encountered during the compile, is any
    >>> parameter or return type checking done by the compiler?

    >>
    >> Yes.
    >>
    >> Next question ...?
    >>

    >
    > This is of course wrong, since regulars play with words here to amuse
    > themselves misleading a person that asks a simple question.


    Jacob, you have confused "prototype" with "declaration."
    Here is a function declaration with no prototype:

    char * myAuntFanny();

    And here is an invocation of the function:

    double trouble = myAuntFanny();

    Now read the O.P.'s question again: "Is any parameter *or*
    *return* *type* checking done by the compiler?"

    --
    Eric Sosman
    lid
    Eric Sosman, Sep 2, 2009
    #7
  8. jacob navia <> writes:

    > Eric Sosman a écrit :
    >> Sortie wrote:
    >>> When a function call is encountered during the compile, is any
    >>> parameter or return type checking done by the compiler?

    >>
    >> Yes.
    >>
    >> Next question ...?
    >>

    >
    > This is of course wrong, since regulars play with words here to amuse
    > themselves misleading a person that asks a simple question.
    >
    > (1) No checks can be done if there is no prototype to the arguments
    > being passed
    >
    > (2) The return type is "int".


    The return type is not always int. The question was about absence of
    prototypes not the absence of declarations.

    As an advocate of C99 you would know that a return type of int can
    only come from a declaration

    > This means that this return type will
    > be checked against assigning it to a structure or any other value
    > incompatible with an integer. That trivial check allows heathfield
    > and company to say "yes" (enigmatically) to demnostrate their knowledge
    > and to mislead the original poster.


    --
    Ben.
    Ben Bacarisse, Sep 2, 2009
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. June Lee
    Replies:
    2
    Views:
    788
    Jim Cobban
    Apr 13, 2008
  2. Carter
    Replies:
    2
    Views:
    490
    Carter
    Mar 4, 2009
  3. Replies:
    9
    Views:
    174
    Thomas 'PointedEars' Lahn
    May 26, 2006
  4. Replies:
    3
    Views:
    257
  5. javascript fish
    Replies:
    0
    Views:
    161
    javascript fish
    Oct 11, 2008
Loading...

Share This Page