This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH:[darwin] fix load of a misaligned double word



On Dec 31, 2003, at 1:08 PM, Andrew Haley wrote:


Bradley Lucier writes:

So it comes down to a quality of implementation question. You're saying that my "implementation defined" code is clearly wrong, and everyone else's "implementation defined" conversion between pointers and ints is OK; I have yet to be convinced.

I don't understand your point. If it is true, as I maintain, that performing arithmetic on an int* and then using the resulting pointer as a double* is undefined, then the code you present is undefined.

Part 7 says


7 A pointer to an object or incomplete type may be converted to a pointer to a different object or incomplete type. If the resulting pointer is not correctly aligned 57) for the pointed-to type, the behavior is undefined. Otherwise, when converted back again, the result shall compare equal to the original pointer. When a pointer to an object is converted to a pointer to a character type, the result points to the lowest addressed byte of the object. Successive increments of the result, up to the size of the object, yield pointers to the remaining bytes of the object.

so looking at my code.


int -> int * is valid, though implementation defined

addition of 1 to int * is valid

int * -> int is valid, though implementation defined

int -> double * is valid, though implementation defined

Even if I went directly from int * -> double *, it would be undefined only if it is not correctly aligned, and I know that it *is* correctly aligned.

That isn't a quality of implementation issue: the code in question
simply doesn't mean anything.

Parts 5 and 6 say that integers may be converted to and from pointers, and the results are implementation defined. Full stop. No restrictions on how you got those integers. That's what I'm doing. It means something, but what it means is "implementation defined". How gcc handles that is a quality of implementation issue.


Brad


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]