linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: Alejandro Colomar <colomar.6.4.3@gmail.com>
Cc: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>,
	linux-man@vger.kernel.org, libc-alpha@sourceware.org,
	gcc@gcc.gnu.org
Subject: Re: [PATCH v2 1/2] system_data_types.7: Add 'void *'
Date: Thu, 8 Oct 2020 15:52:10 +0200	[thread overview]
Message-ID: <20201008135210.GA2956488@cventin.lip.ens-lyon.fr> (raw)
In-Reply-To: <41ab7ed9-3ce0-f8ad-38f4-c4bbeca138f8@gmail.com>

On 2020-10-01 18:55:04 +0200, Alejandro Colomar via Gcc wrote:
> On 2020-10-01 18:38, Michael Kerrisk (man-pages) wrote:
> > > +According to the C language standard,
> > > +a pointer to any object type may be converted to a pointer to
> > > +.I void
> > > +and back.
> > > +POSIX further requires that any pointer,
> > > +including pointers to functions,
> > > +may be converted to a pointer to
> > > +.I void
> > > +and back.
> > I know you are correct about POSIX, but which part of the
> > standard did you find this information in? The only
> > reference that I find in POSIX is the dlsym() spec. Is it
> > covered also somewhere else in the standrd?
[...]
> I've bean searching, and dlsym is the only one:
[...]
> The most explicit paragraph in dlsym is the following:
> 
> [[
> 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.
> ]]

I think that "this conversion" applies only to the dlsym context,
and the conversion isn't defined in general. Imagine that the
void * pointer to function pointer conversion requires the compiler
to generate additional code. The compiler may be able to detect
that dlsym will not be used in some contexts (e.g. because of
always false condition) and do not generate such additional code,
making the conversion to have undefined behavior.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

  parent reply	other threads:[~2020-10-08 14:00 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01 15:06 [PATCH 0/2] Document void * Alejandro Colomar
2020-10-01 15:06 ` [PATCH 1/2] system_data_types.7: Add 'void *' Alejandro Colomar
2020-10-01 15:06 ` [PATCH 2/2] void-*.3: New link to system_data_types(7) Alejandro Colomar
2020-10-01 15:34 ` [PATCH 0/2] Document void * Michael Kerrisk (man-pages)
2020-10-01 15:40   ` Alejandro Colomar
2020-10-01 15:49     ` [PATCH v2 0/2] Document 'void *' Alejandro Colomar
2020-10-01 15:49     ` [PATCH v2 1/2] system_data_types.7: Add " Alejandro Colomar
2020-10-01 16:38       ` Michael Kerrisk (man-pages)
2020-10-01 16:55         ` Alejandro Colomar
2020-10-02 11:54           ` Michael Kerrisk (man-pages)
2020-10-08 13:52           ` Vincent Lefevre [this message]
2020-10-12  9:36             ` Michael Kerrisk (man-pages)
2020-10-01 17:32       ` Paul Eggert
2020-10-02  8:24         ` Alejandro Colomar
2020-10-02  8:48           ` Alejandro Colomar
2020-10-02 11:44             ` Michael Kerrisk (man-pages)
2020-10-02  9:10           ` David Laight
2020-10-02 17:00             ` Paul Eggert
2020-10-02 10:49           ` Jonathan Wakely
2020-10-02 11:31             ` Michael Kerrisk (man-pages)
2020-10-02 13:06               ` Jonathan Wakely
2020-10-02 13:20                 ` Alejandro Colomar
2020-10-02 13:27                   ` Jonathan Wakely
2020-10-02 13:51                     ` Alejandro Colomar
2020-10-03  8:00                       ` Navigational corrections (was: Re: [PATCH v2 1/2] system_data_types.7: Add 'void *') Michael Kerrisk (man-pages)
2020-10-03  9:16                         ` Navigational corrections Alejandro Colomar
2020-10-03 11:39                           ` Michael Kerrisk (man-pages)
2020-10-05 22:08                             ` Alejandro Colomar
2020-10-07  6:53                               ` Michael Kerrisk (man-pages)
2020-10-01 15:49     ` [PATCH v2 2/2] void.3: New link to system_data_types(7) Alejandro Colomar
2020-10-02 13:19     ` [PATCH 0/2] Document void * Jonathan Wakely
2020-10-03 11:44       ` Michael Kerrisk (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201008135210.GA2956488@cventin.lip.ens-lyon.fr \
    --to=vincent@vinc17.net \
    --cc=colomar.6.4.3@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).