This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I am using the C6000 CGT 7.4.4 and I found that a 32 bits pointer(for example uint32_t *a) to access an address no matter it is 4 byte alinged or not, the compiler would use LDW rather than LDNW which assumes the address is 4 byte aligned. If the content of 32 bits pointer is gotten from another type of data (8bits, 16 bits) which is not always 4 byte aligned, it might cause error.
Is there any compiler option can disable this restriction? That being said, the pointer access always read data from its real address even it is not 4 byte aligned.
Thanks,
Adam
Your code example above is a violation of the strict aliasing rule. Long story short, the compiler presumes you will never write code like that. For more details, please see this post.
Thanks and regards,
-George