[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #29537 [Core Tor/Tor]: verify intptr_t round-trip through void *
#29537: verify intptr_t round-trip through void *
----------------------------------------+----------------------------------
Reporter: catalyst | Owner: (none)
Type: defect | Status: needs_revision
Priority: Medium | Milestone: Tor:
| 0.4.1.x-final
Component: Core Tor/Tor | Version:
Severity: Normal | Resolution:
Keywords: portability technical-debt | Actual Points:
Parent ID: | Points:
Reviewer: | Sponsor:
----------------------------------------+----------------------------------
Comment (by rl1987):
Replying to [ticket:29537 catalyst]:
> Round-trip of `intptr_t` through `void *` isn't explicitly guaranteed by
C99. There are implementation-defined behaviors for integer to `void *`,
and vice versa. Only a round-trip of `void *` through `intptr_t` is
guaranteed, not vice versa.
Is that true though?
From http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf:
>7.18.1.4 Integer types capable of holding object pointers
>1 The following type designates a signed 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:
>intptr_t
>The following type designates 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:
>uintptr_t
>These types are optional.
My reading of this is that it does guarantee the round-trip for all values
between `INTPTR_MIN` and `INTPTR_MAX` provided that C implementation does
have `intptr_t`. Or does C99 standard (which people are supposed to
purchase from ISO) say differently?
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/29537#comment:5>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs