freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] LLP64 model outside Win64


From: Behdad Esfahbod
Subject: Re: [ft-devel] LLP64 model outside Win64
Date: Sun, 11 Feb 2018 20:31:00 -0800

On Feb 11, 2018 8:15 PM, "Alexei Podtelezhnikov" <address@hidden> wrote:
>>>>
>>>>   (void *)(((char *)0) + (x))
>>>>
>
> Wow! Very cool!
>
>
> I'm fairly sure that's undefined in C standard as well.

(void *)((char *)NULL + (x)) ??

Yes. C99 has:

"""
8 When an _expression_ that has integer type is added to or subtracted from a pointer, the
result has the type of the pointer operand. If the pointer operand points to an element of
an array object, and the array is large enough, the result points to an element offset from
the original element such that the difference of the subscripts of the resulting and original
array elements equals the integer _expression_. In other words, if the _expression_ P points to
the i-th element of an array object, the expressions (P)+N (equivalently, N+(P)) and
(P)-N (where N has the value n) point to, respectively, the i+n-th and i−n-th elements of
the array object, provided they exist. Moreover, if the _expression_ P points to the last
element of an array object, the _expression_ (P)+1 points one past the last element of the
array object, and if the _expression_ Q points one past the last element of an array object,
the _expression_ (Q)-1 points to the last element of the array object. If both the pointer
operand and the result point to elements of the same array object, or one past the last
element of the array object, the evaluation shall not produce an overflow; otherwise, the
behavior is undefined. If the result points one past the last element of the array object, it
shall not be used as the operand of a unary * operator that is evaluated.
"""

Ie. You can only do pointer arithmetic within an allocate array. All else is undefined. Which makes sense for same reasons that Roland mentioned (segmented architectures.)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]