Re: [PATCH] C undefined behavior fix

Florian Weimer
2002-01-04T09:08:20Z

Paul Mackerras <paulus@samba.org> writes:

> Richard Henderson writes:
>
>> On Thu, Jan 03, 2002 at 01:33:27PM +1100, Paul Mackerras wrote:
>> > I look forward to seeing your patch to remove all uses of
>> > virt_to_phys, phys_to_virt, __pa, __va, etc. from arch/alpha... :)
>>
>> I don't dereference them either, do I?
>
> Does that matter?

No, it doesn't. C pointers do not behave like machine addresses,
there are additional constraints.

> Also, what does the standard say about casting pointers to integral
> types? IIRC you aren't entitled to assume that a pointer will fit in
> any integral type, or anything about the bit patterns that you get.

This casting falls into the category "additional language constructs
supported by GCC". The standard contains wording which encourages
implementors to include a meaningfull conversion from a pointer type
to an integral type, but there is no requirement that this has the
semantics expected by most programmers.