This is the mail archive of the gcc-help@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: alias question


On 02/18/2011 10:02 AM, xorbe wrote:

If I have a char array, and it's always written by the char array,
can it be always reliably read by any combination of
short/int/long pointers?

As I understand, the compiler will see byte writes for all types,
so readind shoulg be fine without violating any strict alias
rules.  Just can't write the array by any other type than char[]
access.  Right?

No. You can access anything only as its declared type or character type; an array of char thus can be accessed as char only.

However, what I said is walking the fine line of following that rule. I have several overlapping read-only types, BUT they are only written as char. Hence, they'll always resolve to the correct value. I haven't been able to construct any code which fails to work yet. If a char write precedes a type's access to the same location, then it will be seen. As far as I can tell, that basic rule is followed here!

I think not, but you haven't described what you're doing with sufficient precision for us to be able to tell for sure.

Andrew.


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