Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
MISRA-C meeting 23-8-2006.
Code:
s16c = (int16_t)(s32a * s32b);
Having made the cast explicit, it is still necessary to be sure that the cast results in no loss of infomation.
The cast makes it clear this is a 16 bit constraint.
Implicit narrowing casts are prohibited by 10.1.
Posted by and on behalf of the MISRA C Working Group
Posts: 107
Threads: 80
Joined: May 2004
Reputation:
3
The date is there for reference of when this issue was reviewed - there are no minutes as such but questions reviewed by the MISRA C Working Group are posted with an official reply (from the \"misra-c\" user).
If you could repost your question here it would be helpful and the MISRA C Group will give an official reply in due course. You might also find the MISRA C Technical Corrigendum (accessible in the \"Resources\" section to registered users of this forum) useful.
Dr David Ward
MISRA Operations Director
Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
10.3 and 10.4 do apply to explicit casts. They are in the section 6.10.7 entitled \"Explicit conversions (casts)\".
Therefore the example above clearly illustrates the intent of MISRA-C and is correct in its reasoning.
Posted by and on behalf of the MISRA C Working Group