Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - 4.2.1 and type-punning in PxConfigReadInt() call: Page 1 of 8 (8 Items)
   
4.2.1 and type-punning in PxConfigReadInt() call  
We're moving a large ARM based project from 2.95 to the 4.2.1 compiler and it generates of type-punning warnings. The 
warnings say

"warning: dereferencing type-punned pointer will break strict aliasing rules"

and always come on PxConfigReadInt() calls like this:

PxConfigReadInt( section, "pwrunits", DPWRW, (int *)&buf->pwrunits);

It seems not to like the (int *) cast on the unary & operator when the pointer references an enum type. Changing the 
code like this eliminates the warning

int tp;
tp = (int) buf->pwrunits;
PxConfigReadInt( section, "pwrunits", DPWRW, &tp);
buf->pwrUnits = tp;

but that seems like stupid-work.

Strict aliasing can be turned off but without fully understanding the issue that seems like a questionable move.

Where is the type-pun in this call? I don't see it, but then I'm no expert at C arcana.