when is typecasting (unsigned char*) to (char*) dangerous?

S

Shao Miller

Keith Thompson said:
Tim Rentsch said:
On 11/15/2011 14:59, tim wrote:
thanks in advance for your help, tim

This one bothers me. We have:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1310.htm

That says:

It is clear from the standard (specifically 6.2.6.2p1) that
unsigned integer types in general are not allowed to have trap
representations, and that unsigned char is not allowed to have
any padding bits.

I don't believe that conclusion is correct. 6.2.6.2p1, both in C99 and
in C11 (N1570) defines a value of an unsigned type in terms of the value
bits, but unsigned types can also have padding bits, [snip]

I assume he meant unsigned types cannot have trap representations
considering just the value bits. Of course unsigned types can
have TRs if they do have padding bits, but not if they don't
(as is always the case for unsigned char).

I think that's a strained interpretation.

I don't disagree. I put it forward only as a reasonably plausible
interpretation considering the circumstances. I prefer to give
people the benefit of the doubt, especially when (as is true in
this case) there is reason to expect they deserve it.
It says "unsigned integer
types in general are not allowed to have trap representations";
I take that to mean that unsigned integer types are not allowed to
have trap representations (which is clearly incorrect).

I've just e-mailed the author; I'll let you know if I get a response.

Thank you, I'm interested to hear the result.

I'd e-mailed Mr. Clark Nelson before this and he'd granted me these, for
what they're worth:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1300.pdf
The minutes of the meeting at which the issue was discussed and resolved.

http://www.open-std.org/jtc1/sc22/wg14/11422
The WG14 email message in which I first presented the issue.

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#240
The C++ committee issue whose discussion brought the issue to light.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top