public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Remus Clearwater <remus.clearwater@gmail.com>
To: Godmar Back <godmar@gmail.com>
Cc: libc-help@sourceware.org
Subject: Re: Undefined behaviour code used in sysdeps/unix/sysv/linux/x86_64/makecontext.c
Date: Mon, 21 May 2018 13:18:00 -0000	[thread overview]
Message-ID: <CAMjELSuRomq+TNA34Bvsx0t2Dg7-+u8-fPmh3NpYxLNOV4q81Q@mail.gmail.com> (raw)
In-Reply-To: <CAMjELSuTqcSxTt2xvGRG0ByE+7xKfa7PnK+STS+xOsgMiVOCVg@mail.gmail.com>

PS:

The definition of uintptr_t in C99 is:

“an unsigned integer type with the property that any valid pointer to void
can be converted to this type, then converted back to pointer to void, and
the result will compare equal to the original pointer”

On Mon, May 21, 2018 at 9:08 PM, Remus Clearwater <
remus.clearwater@gmail.com> wrote:

> Sorry for forgot to CC libc-help.
>
> ----
>
> ​Thanks a lot Godmar.
>
> But it didn't say `sizeof(function_pointer)` are must equal or less than
> `sizeof(void*)`.
>
> I found this in POSIX.1-2008 http://pubs.opengroup.org/onli
> nepubs/9699919799.2008edition/functions/V2_chap02.html#tag_15_12_03:
>
> "All function pointer types shall have the same representation as the type
> pointer to void. Conversion of a function pointer to void * shall not alter
> the representation. A void * value resulting from such a conversion can be
> converted back to the original function pointer type, using an explicit
> cast, without loss of information.
>
> Note:
> The ISO C standard does not require this, but it is required for POSIX
> conformance."
>
> So under POSIX.1-2008 the kinda usage of `function_address = (uintptr_t)
> funcfp;` is correct, but in POSIX.1-2017 this section 2.13.3 has been
> removed. This means in POSIX.1-2017 that kinda conversition is still not
> defined.
>
>

  reply	other threads:[~2018-05-21 13:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-21  4:32 Remus Clearwater
2018-05-21 11:39 ` Godmar Back
     [not found]   ` <CAMjELStuFqCE3iVUR-ju3nZqG89dzfPET9kTWniz+kGPOm12ug@mail.gmail.com>
2018-05-21 13:09     ` Fwd: " Remus Clearwater
2018-05-21 13:18       ` Remus Clearwater [this message]
2018-05-21 14:27         ` Godmar Back
2018-05-22  6:47           ` Remus Clearwater
2018-05-22 11:21 ` Florian Weimer

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=CAMjELSuRomq+TNA34Bvsx0t2Dg7-+u8-fPmh3NpYxLNOV4q81Q@mail.gmail.com \
    --to=remus.clearwater@gmail.com \
    --cc=godmar@gmail.com \
    --cc=libc-help@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).