Strict aliasing

Aliasing occurs when two variable points to the same location in memory, like

int a = 12;
int ptr = &a;

Strict aliasing is the assumption from the compiler that pointers won’t alias to a different type object. This allows the compiler to generate more efficiente code. For example:

uint32_t a = 0xFFFF;
uint16_t ptr = &a;

Altough it will compile, there’s no guarantee that ptr will work.

Further reading

http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s