Re: the & pointer operator to yield an address



Alef.Veld@xxxxxxxxx wrote:
On Jan 31, 1:25 am, gordonb.hr...@xxxxxxxxxxx (Gordon Burditt) wrote:
Often &ptr is passed to func because func is going to store something
in ptr. func(&ptr) is perfectly legal if ptr is uninitialized.
func(ptr) is not.

What happens exactly though if you would do that. It probably just
copy the
'nothingness'/garbage into the new functions argument pointer, making
it
a copy of a unintialized pointer.

You're not supposed to read invalid pointers in C, even if you don't
dereference them. If you do, the implementation is allowed to do
anything it wants. At least one implementation (optionally) uses this
permission to cause the program to warn the user that the code is
buggy, and to provide the user with an option to directly abort the
program.

.



Relevant Pages

  • Re: Typecasting pointers
    ... array of shorts, and initialize them all to the same value. ... You're saving the value of ptr so you can freeit later. ... A pointer increment advances the pointer by one object size, ... optimizing compiler could have done a better job than you have. ...
    (comp.lang.c)
  • RE: Multiple pointer entry`s for pc`s
    ... Pointer (PTR) RRs are used to support the reverse ... resolve this information to the DNS domain name for that computer. ... PTR RRs can be added to a zone in several ways: ...
    (microsoft.public.win2000.dns)
  • Re: use delete to destroy primitive/object types but memory is not freed
    ... the safest approach is to think of a pointer as an opaque ... The call to mallocallocates memory space for a double object; ... We then assign a value to the double object that ptr points to, ... The C runtime system has reserved that chunk of memory, ...
    (comp.lang.c)
  • Re: How to know the memory pointed by a ptr is freed?
    ... Section 3.3.4 of the C89 standard expressly allows conversions between ... the integer type is wide enough to hold a pointer. ... The pointer might be loaded in to an address register causing the ... Why would the contents of "ptr" be placed into an address ...
    (comp.lang.c)
  • Re: How to know the memory pointed by a ptr is freed?
    ... > And what about the 37 copies made of that pointer after it was ... the value of "ptr" ... pattern stored in "ptr", or does it mean that we cannot under any ... that we gave that memory back to the system and any access to it ...
    (comp.lang.c)