From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47581 invoked by alias); 21 May 2018 13:18:48 -0000 Mailing-List: contact libc-help-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: libc-help-owner@sourceware.org Received: (qmail 47564 invoked by uid 89); 21 May 2018 13:18:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:alternative X-HELO: mail-qk0-f172.google.com Received: from mail-qk0-f172.google.com (HELO mail-qk0-f172.google.com) (209.85.220.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 May 2018 13:18:46 +0000 Received: by mail-qk0-f172.google.com with SMTP id s70-v6so11723440qks.13 for ; Mon, 21 May 2018 06:18:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=b6QilJny7rMiI8GLXrJMpjUw8kEDuB0cpI8/N+BZp5c=; b=buIkgFY9q11yo3mrA9378r74L+QlV2vIrlXXsVD5uo6y347hXgiaiyJno6x9Oy83d0 kRfkC3CLQ3KJtgzSKMtIo8UzPN/Vbb9HPH6dZH2R7BZ2MrxZrAbYTn8kanvR5GFx1X// eVkikeLI3IhVt/YPJMxzkjyEZx/jZg0AwzDmdyZPWEiWhsRruBlTQEZ3Wemd4SvRaniO UQaMEP1H6fVTH9CGGEOAtDPJ3Z1dJzWZ6x79pelQybaquMZIM5nyGIL5KToCp3b+1d5J ot51z/Qmg7piBGF0VRXV+45tvfCiKIG8t6Ml4iR7WYgw5+KNYUNeGQoQYCT4Ro8K82GT 0Vbw== X-Gm-Message-State: ALKqPwdU/BW7CTv0pN8NhHE8lQLxbGnPJMq84lmSr4hTJfkmCdxV323S J6K+adjt9jbqHj2pJsLNgadqarObrZ3XwmNtlU0= X-Google-Smtp-Source: AB8JxZr7tCLbNCPie83z+2yX484wMos0parEPxR0gJyhxChgdAuQgKHR2fuNgCAZdwlY6fDYWMJB25oxNO3SorLfL3g= X-Received: by 2002:a37:db0a:: with SMTP id e10-v6mr9640020qki.291.1526908724253; Mon, 21 May 2018 06:18:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.232.13 with HTTP; Mon, 21 May 2018 06:18:43 -0700 (PDT) In-Reply-To: References: From: Remus Clearwater Date: Mon, 21 May 2018 13:18:00 -0000 Message-ID: Subject: Re: Undefined behaviour code used in sysdeps/unix/sysv/linux/x86_64/makecontext.c To: Godmar Back Cc: libc-help@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-05/txt/msg00024.txt.bz2 PS: The definition of uintptr_t in C99 is: =E2=80=9Can 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=E2=80=9D On Mon, May 21, 2018 at 9:08 PM, Remus Clearwater < remus.clearwater@gmail.com> wrote: > Sorry for forgot to CC libc-help. > > ---- > > =E2=80=8BThanks 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 alt= er > 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 =3D (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. > >