8 bytes into 2 bytes fits ?
David C Binderman
dcb@pncl.co.uk
Thu Sep 10 17:58:00 GMT 1998
At 12:51 AM 9/9/98 z, you wrote:
>David C Binderman <dcb@pncl.co.uk> writes:
>
>> At 10:31 PM 9/2/98 -0300, you wrote:
>>> David C Binderman <dcb@pncl.co.uk> writes:
>>>
>>>> surely pointers can only be cast to types big enough to hold them.
>>>
>>> Casting a pointer (but not a pointer to member) to any integral type
>>> has always been allowed.
>
>> Not in my experience of C++.
>
>You've got good experience, indeed. :-)
Thanks.
I think it's so complex, that it'll keep me for at least another five
years ;->
>[expr.reinterpret.cast]/4 says that a pointer can be explicitly
>converted to any integral type *large enough to hold it*.
Which makes it compiler and machine dependent. I think it is safe territory
for egcs to error for trying to put a pointer into a char or a short,
(as my example code showed), but into an int (or long) is
more problematic.
>And I'm
>happy I can't find any other kind of cast that would allow such a
>lossy conversion. Looks like the C++ standard fixed this C problem.
>Or wasn't that allowed not even in C?
The C part of egcs would be well advised to produce a warning for
these lossy conversions.
Regards
David C Binderman MSc BSc +44 1293 534847 dcb@pncl.co.uk
More information about the Gcc
mailing list