![]() |
![]() |
0306 | ![]() |
||||
![]() | |||||||
| Pointers | REFERENCE - ISO:C90-6.3.4 Cast Operators - Semantics | ||||||
A cast is being performed between an integral type and a pointer to object type, or vice versa. Any cast which maps integer values to pointer values is by nature implementation-defined. When casting from a pointer type to an integer type, the size of integer which is required will also be implementation defined. However this type of operation is not uncommon in embedded software applications where memory mapped I/O ports must be addressed. Message 0303 will identify integer/pointer casts where the pointer addresses a volatile object. Message 0306 will identify integer/pointer casts where the pointer does not address a volatile object. For example:
/*PRQA S 2017,2200,3120,3198,3199,3203,3211,3408,3447,3602 ++*/
extern unsigned char * puc;
extern volatile unsigned char * pvuc;
extern void foo(void)
{
unsigned short mus;
unsigned long mul;
pvuc = (volatile unsigned char *)0xFF00U; /* Message 0303 */
mul = (unsigned long)pvuc; /* Message 0303 */
mus = (unsigned short)pvuc; /* Message 0303 and 0309 */
puc = (unsigned char *)0xFF00U; /* Message 0306 */
mul = (unsigned long)puc; /* Message 0306 */
mus = (unsigned short)puc; /* Message 0306 and 0309 */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |