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


Groups > comp.lang.c > #89453

Re: size of pointers to functions and size of pointer to data question

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: size of pointers to functions and size of pointer to data question
Date 2016-06-17 13:14 -0700
Organization None to speak of
Message-ID <lnziqjtvwm.fsf@kst-u.example.com> (permalink)
References <167656d7-b216-4a24-8b96-d73bf85e81aa@googlegroups.com>

Show all headers | View raw


G G <gdotone@gmail.com> writes:
> is the size of a pointer to a function the same size of a 
> pointer to data on a given width of processor?
> 8 bit, 16 bit, 32 bit, 64 bit.

Maybe.  (Incidentally, I don't believe a conforming implementation could
have 8-bit pointers, at least not a conforming hosted implementation.)

> does the latest specification of the language dictate 
> sizing of the pointer between pointer to function or pointer to data?

No.

> And if different, why?

Many, probably most implementations use the same size and
representation for all pointer types.  Those that don't would
have their own implementation-specific reasons for making them
different.  I've heard of systems (AS/400, maybe?) where function
pointers contain extra informatoin.  Or a function pointer could be
implemented as an index into a table (I haven't heard of a system
that actually does that).

POSIX requires the result of dlsym() (a void*) to be convertible to a
function pointer without loss of information.  The simplest way to do
that is for them to have the same representation, or at least for void*
to be at least as big as a function pointer, but POSIX permits other
approaches.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


Thread

size of pointers to functions and size of pointer to data question G G <gdotone@gmail.com> - 2016-06-17 12:13 -0700
  Re: size of pointers to functions and size of pointer to data question supercat@casperkitty.com - 2016-06-17 12:24 -0700
  Re: size of pointers to functions and size of pointer to data question James Kuyper <jameskuyper@verizon.net> - 2016-06-17 16:06 -0400
    Re: size of pointers to functions and size of pointer to data question James Kuyper <jameskuyper@verizon.net> - 2016-06-17 16:18 -0400
      Hope springs eternal (Was: size of pointers to functions and size ...) question gazelle@shell.xmission.com (Kenny McCormack) - 2016-06-20 14:27 +0000
  Re: size of pointers to functions and size of pointer to data question Keith Thompson <kst-u@mib.org> - 2016-06-17 13:14 -0700
    Re: size of pointers to functions and size of pointer to data question David Brown <david.brown@hesbynett.no> - 2016-06-19 18:28 +0200
      Re: size of pointers to functions and size of pointer to data question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-19 19:57 +0100
        Re: size of pointers to functions and size of pointer to data question supercat@casperkitty.com - 2016-06-19 12:32 -0700
          Re: size of pointers to functions and size of pointer to data question Keith Thompson <kst-u@mib.org> - 2016-06-19 15:29 -0700
            Re: size of pointers to functions and size of pointer to data question supercat@casperkitty.com - 2016-06-20 08:57 -0700
  Re: size of pointers to functions and size of pointer to data question Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-17 16:49 -0400
    Re: size of pointers to functions and size of pointer to data question Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-17 16:54 -0400
      Re: size of pointers to functions and size of pointer to data question James Kuyper <jameskuyper@verizon.net> - 2016-06-17 17:15 -0400
        Re: size of pointers to functions and size of pointer to data question supercat@casperkitty.com - 2016-06-17 15:04 -0700
  Re: size of pointers to functions and size of pointer to data question Robert Wessel <robertwessel2@yahoo.com> - 2016-06-17 23:37 -0500

csiph-web