Re: Difference between variables and functions

From: Ulrich Hobelmann (u.hobelmann_at_web.de)
Date: 08/30/05

  • Next message: axel_at_white-eagle.invalid.uk: "Re: Jargons of Info Tech industry"
    Date: Tue, 30 Aug 2005 13:07:53 +0200
    
    

    joe@invalid.address wrote:
    > The OP's code set an int to 4. Then it tried to call the value 4 as a
    > function, which would mean (I guess) that the compiler was expected to
    > generate code that would just jump to address 4 and start executing.
    >
    > There have been several good responses based on the definition of
    > C. I'm just wondering why you think it would be a good thing for the
    > compiler to blissfully cast the number 4 to a pointer to function and
    > try to start executing code at that address?

    No, as Keith writes, I was under the impression that C had somewhat
    loose type-checking, when often it doesn't. Thanks to you guys for
    educating me!

    > I'm not an expert though, I'm just asking. The fact that it won't do
    > that seems more like reasonable than anal to me.

    Sure, the call doesn't make sense. It was my wrong understanding of C's
    type system that led me to expect that a call to "4" should be compiled ;)

    -- 
    My ideal for the future is to develop a filesystem remote interface
    (a la Plan 9) and then have it implemented across the Internet as
    the standard rather than HTML.  That would be ultimate cool.
    	Ken Thompson
    

  • Next message: axel_at_white-eagle.invalid.uk: "Re: Jargons of Info Tech industry"

    Relevant Pages

    • Re: Difference between variables and functions
      ... > allocation). ... I assumed that it's all just memory addresses ... which would mean that the compiler was expected to ... try to start executing code at that address? ...
      (comp.unix.programmer)
    • Re: curious about array initialization.
      ... Keith Thompson wrote: ... means its a base of knowledge by which you have universal understanding ... the compiler doesn't have to allocate storage for the string literal. ... That the standard is not something from which you can derive ...
      (comp.lang.c)
    • Re: compiler generated output
      ... compiler to generate code which only uses 386 instruction). ... Thus, while replacing mov/and with movzx, the jump is still there. ... 00000001`00001c65 66894c2408 mov,cx ...
      (comp.lang.asm.x86)
    • Re: How while loop works
      ... I have doubt regarding how compiler understands about while loop. ... value - assigns value to register n ... JLE address - if last value compared was negative, jump to given address ...
      (comp.lang.c)
    • Re: not able to compile fftw3 with ifc 7.1
      ... > A new compiler won't help you. ... I found your explanation very helpful at understanding ... > spend some time over in the CS department there at Cornell while you ... processors etc so portability is of vital importance. ...
      (comp.lang.fortran)