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


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

Re: “ChattyG takes a college freshman C/C++ programming exam”

Path csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups comp.lang.c++
Subject Re: “ChattyG takes a college freshman C/C++ programming exam”
Date Wed, 11 Oct 2023 07:56:18 -0700
Organization A noiseless patient Spider
Lines 80
Message-ID <86sf6hb431.fsf@linuxsc.com> (permalink)
References <ufne0r$15ple$1@dont-email.me> <20231007235448.25c4986f123c88ff65d2f103@gmail.moc> <uftmh9$2vieq$1@dont-email.me> <20231008125543.518cab44cdefed7e8af393c8@gmail.moc> <pan$93d59$b5109882$fbf405c8$d4bea16f@invalid.invalid> <87cyxovj92.fsf@nosuchdomain.example.com> <ug0230$3lhhc$1@dont-email.me> <87lecaszhf.fsf@nosuchdomain.example.com>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info dont-email.me; posting-host="c9974d524a342450c72757464b9d47a6"; logging-data="1993712"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MhqJQVhip0TUFcVmiaYJ5l0zC2gqF+RE="
User-Agent Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock sha1:h8NzRLyaQenBggIDLc6bXZxXd/4= sha1:OUb9KO/WenCG4Za3gusAbp7zdXg=
Xref csiph.com comp.lang.c++:92578

Show key headers only | View raw


Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>
>> On 10/8/23 18:31, Keith Thompson wrote:
>>
>>> Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> writes:

[..converting a void* to a pointer to function..]

>>>> It mayn't be supported in standard C, but it's a common
>>>> extension?in fact, POSIX _requires_ it in order for the dlsym
>>>> subroutine to work.
>>>
>>> The POSIX requirement is limited to values returned by dlsym().
>>>
>>> https://pubs.opengroup.org/onlinepubs/9699919799/functions/dlsym.html
>>
>> I've heard that before, and it might be true - but I don't see
>> words to that effect on that page.  It says:
>>
>> "Note that conversion from a void * pointer to a function pointer
>> as in:
>>
>> fptr = (int (*)(int))dlsym(handle, "my_function");
>>
>> is not defined by the ISO C standard.  This standard requires
>> this conversion to work correctly on conforming implementations."
>>
>> As I read it, that requires that the conversion work in general -
>> it says nothing about it working only for values returned by
>> dlsym.
>
> I'd say it's ambiguous.  One could argue that "this conversion" refers
> to converting the result of a call to dlsym().

Right.  The "this conversion" might be intended or construed to
refer to "conversion from a void * pointer to a function pointer"
or to the conversion in 'int (*)(int))dlsym([...])'.  That's how
English works.  A good editor who is paying attention would flag
it as an ambiguity.

> And if I were trying to create a POSIX-conforming implementation
> on a system where function pointers cannot in general be converted
> to void* and back again, I'd argue exactly that.  (Imagine, for
> example, a system where function pointers are 128 bits and object
> pointers, including void*, are 64 bits, but the implementation can
> arrange for functions whose addresses might be returned by dlsym()
> to have all zeros in their high-order 64 bits.)

Requiring all function pointers to be convertible to and from a
'void *' pointer seems overly limiting, I agree.

> I *think* the wording was changed at some point, and that an
> earlier version of POSIX required all function pointers to be
> convertible to void*, but I can't find a reference.
> (opengroup.org has links to older versions of POSIX from 2008,
> 2013, and 2016, but when I search for "dlsym" in any of them it
> takes me to the current version.)

In the 2004 edition, this page

  https://pubs.opengroup.org/onlinepubs/009604499/functions/dlsym.html

has this sentence

    Implementations supporting the XSI extension, however, do
    require that an object of type void * can hold a pointer to a
    function.

and this sentence

    Due to the problem noted here, a future version may either
    add a new function to return function pointers, or the
    current interface may be deprecated in favor of two new
    functions:  one that returns data pointers and the other that
    returns function pointers.

No conclusions, I was thinking mainly that the link might be of
some value or interest.

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


Thread

“ChattyG takes a college freshman C/C++ programming exam” Lynn McGuire <lynnmcguire5@gmail.com> - 2023-10-05 17:40 -0500
  Re: “ChattyG takes a college freshman C/C++ programming exam” "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-05 15:57 -0700
  Re: “ChattyG takes a college freshman C/C++ programming exam” Christian Gollwitzer <auriocus@gmx.de> - 2023-10-06 07:36 +0200
    Re: “ChattyG takes a college freshman C/C++ programming exam” "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-06 11:59 -0700
  Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@gmail.moc> - 2023-10-07 23:54 +0300
    Re: “ChattyG takes a college freshman C/C++ programming exam” jak <nospam@please.ty> - 2023-10-08 09:42 +0200
      Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-08 04:27 -0400
      Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@gmail.moc> - 2023-10-08 12:55 +0300
        Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@gmail.moc> - 2023-10-08 13:06 +0300
        Re: “ChattyG takes a college freshman C/C++ programming exam” candycanearter07 <no@thanks.net> - 2023-10-08 06:22 -0500
          Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@gmail.moc> - 2023-10-08 15:03 +0300
            Re: “ChattyG takes a college freshman C/C++ programming exam” Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-10-15 15:51 -0400
              Re: “ChattyG takes a college freshman C/C++ programming exam” Richard Damon <richard@damon-family.org> - 2023-10-15 17:53 -0400
              Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-16 00:07 -0400
                Re: “ChattyG takes a college freshman C/C++ programming exam” Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2023-10-16 22:01 -0400
                Re: “ChattyG takes a college freshman C/C++ programming exam” Richard Damon <richard@damon-family.org> - 2023-10-16 22:41 -0400
                Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-17 12:22 -0400
          Re: “ChattyG takes a college freshman C/C++ programming exam” "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-08 12:31 -0700
            Re: “ChattyG takes a college freshman C/C++ programming exam” Richard Damon <news.x.richarddamon@xoxy.net> - 2023-10-08 21:17 -0400
              Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-09 01:13 -0400
                Re: “ChattyG takes a college freshman C/C++ programming exam” "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-10 12:18 -0700
            Re: “ChattyG takes a college freshman C/C++ programming exam” MarioCCCP <NoliMihiFrangereMentulam@libero.it> - 2023-10-13 11:22 +0200
              Re: “ChattyG takes a college freshman C/C++ programming exam” Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-10-13 10:04 -0700
        Re: “ChattyG takes a college freshman C/C++ programming exam” Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-10-08 13:54 +0100
        Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-08 11:25 -0400
          Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@gmail.moc> - 2023-10-08 20:07 +0300
        Re: “ChattyG takes a college freshman C/C++ programming exam” Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2023-10-08 16:37 +0000
          Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@gmail.moc> - 2023-10-08 20:05 +0300
            Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-09 01:13 -0400
              Re: “ChattyG takes a college freshman C/C++ programming exam” "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-09 13:30 -0700
                Re: Re: “ChattyG takes a college freshman C/C++ programming exam” scott@slp53.sl.home (Scott Lurndal) - 2023-10-09 20:33 +0000
                Re: “ChattyG takes a college freshman C/C++ programming exam” "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-10 12:04 -0700
            Re: “ChattyG takes a college freshman C/C++ programming exam” Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2023-10-09 12:17 +0000
              Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@gmail.moc> - 2023-10-09 23:03 +0300
                Re: “ChattyG takes a college freshman C/C++ programming exam” scott@slp53.sl.home (Scott Lurndal) - 2023-10-09 20:30 +0000
                Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@gmail.moc> - 2023-10-09 23:45 +0300
                Re: “ChattyG takes a college freshman C/C++ programming exam” scott@slp53.sl.home (Scott Lurndal) - 2023-10-09 21:21 +0000
                Re: “ChattyG takes a college freshman C/C++ programming exam” scott@slp53.sl.home (Scott Lurndal) - 2023-10-09 21:26 +0000
                Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-09 22:41 -0400
                Re: “ChattyG takes a college freshman C/C++ programming exam” Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-10-09 21:47 +0100
          Re: “ChattyG takes a college freshman C/C++ programming exam” Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-10-08 15:31 -0700
            Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-09 01:12 -0400
              Re: “ChattyG takes a college freshman C/C++ programming exam” Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-10-10 18:46 -0700
                Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-11 01:14 -0400
                Re: “ChattyG takes a college freshman C/C++ programming exam” scott@slp53.sl.home (Scott Lurndal) - 2023-10-11 13:47 +0000
                Re: “ChattyG takes a college freshman C/C++ programming exam” Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-10-11 07:56 -0700
            Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@gmail.moc> - 2023-10-09 23:06 +0300
              Re: “ChattyG takes a college freshman C/C++ programming exam” Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-10-09 17:15 -0700
      Re: “ChattyG takes a college freshman C/C++ programming exam” James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-10-08 11:08 -0400
  Re: “ChattyG takes a college freshman C/C++ programming exam” "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-11 21:06 -0700
    Re: “ChattyG takes a college freshman C/C++ programming exam” "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-11 21:10 -0700
    Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@g{oogle}mail.com> - 2023-10-12 10:56 +0300
    Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@g{oogle}mail.com> - 2023-10-12 10:57 +0300
      Re: “ChattyG takes a college freshman C/C++ programming exam” "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-10-12 12:59 -0700
  Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@g{oogle}mail.com> - 2023-10-12 10:53 +0300
    Re: “ChattyG takes a college freshman C/C++ programming exam” Phil Carmody <pc+usenet@asdf.org> - 2023-10-23 15:39 +0300
      Re: “ChattyG takes a college freshman C/C++ programming exam” Anton Shepelev <anton.txt@g{oogle}mail.com> - 2023-10-23 16:45 +0300

csiph-web