Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #10871

Re: pointers

From jt@toerring.de (Jens Thoms Toerring)
Newsgroups comp.lang.c++
Subject Re: pointers
Date 2011-10-15 22:27 +0000
Organization Freie Universitaet Berlin
Message-ID <9fufm2FcibU1@mid.uni-berlin.de> (permalink)
References (2 earlier) <etrjm8-efs.ln1@hurricane.fredriksson.dy.fi> <j77vek$44m$1@dont-email.me> <4e986f9a$0$5796$65785112@news.neostrada.pl> <9fronaFng1U1@mid.uni-berlin.de> <pointers-20111015030645@ram.dialup.fu-berlin.de>

Show all headers | View raw


Stefan Ram <ram@zedat.fu-berlin.de> wrote:
> jt@toerring.de (Jens Thoms Toerring) writes:
> >And when you add a number to a memory address in assembler
> >the result is the direct sum of that number and the address,
> >while for a pointer it's the original value plus the product
> >of the number and the size of the type of what the pointer
> >points to.

>   I do not believe that this applies to functions pointers.

>   It might apply to object pointers. While one cannot say that
>   object pointers are memory addresses, one might say that
>   they are array addresses: p+1 points to the next object in
>   an array of objects of the type of *p.

Yes, you're right, of course. I should have mentioned function
pointers - or void pointers - those make it even more obvious
that a "pointer" isn't "just a memory address".

>   However, some programs use only pointers, but do not use
>   pointer arithmetics. To understand such programs, it might
>   help to think of the pointers as being memory addresses.

But then there's still the issue of what happens "under the
hood" when dereferencing a pointer - in assembler you have
to spell out how many bytes should be involved (readb, readw
or readl etc. or similar and the same holds for writing) while
with a pointer the compiler "knows" what's the correct thing
to do.
                        Best regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

RIP Dennis Ritchie Leigh Johnston <leigh@i42.co.uk> - 2011-10-13 15:38 +0100
  Re: RIP Dennis Ritchie "A" <a@a.a> - 2011-10-13 16:43 +0200
  Re: RIP Dennis Ritchie Paul Kuriakose <paul.kuriakose@comcast.net> - 2011-10-13 10:45 -0400
  Re: RIP Dennis Ritchie Lynn McGuire <lmc@winsim.com> - 2011-10-13 14:22 -0500
    Re: RIP Dennis Ritchie Donkey Hottie <donkey@fredriksson.dy.fi> - 2011-10-13 22:53 +0300
      Re: RIP Dennis Ritchie red floyd <no.spam.here@its.invalid> - 2011-10-13 17:23 -0700
        Re: RIP Dennis Ritchie Szyk <szyk100@o2.pl> - 2011-10-14 19:21 +0200
          Re: RIP Dennis Ritchie jt@toerring.de (Jens Thoms Toerring) - 2011-10-14 21:43 +0000
            Re: pointers jt@toerring.de (Jens Thoms Toerring) - 2011-10-15 22:27 +0000
            Re: pointers Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-10-15 22:52 +0000
            Re: pointers Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2011-10-15 19:38 -0400
              Re: pointers yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-10-17 10:46 +0000
            Re: pointers (was: RIP Dennis Ritchie) Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-10-17 03:01 -0700
            Re: RIP Dennis Ritchie Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-10-17 03:00 -0700
              Re: RIP Dennis Ritchie Markus Wichmann <nullplan@gmx.net> - 2011-10-18 10:35 +0200

csiph-web