![]() |
![]() |
2945 | ![]() |
||||
![]() | |||||||
| Conversion to signed | |||||||
A negative value is being cast to a signed type and the value is such that it can only be represented in a signed type of this size in a two's-complement form. In practice, two's complement representation is almost universal in modern computers, but other binary representations do exist. Message 2945 will be generated when:
/*PRQA S 274,280,1278,2017,2982,2984,3120,3198,3210,3212,3408,3447,3602,3606 ++*/
/***************************************************/
/* OPTIONS: -s int=16 */
/***************************************************/
extern signed char sca;
extern signed short ssa;
extern signed int sia;
extern void foo(void)
{
sca = (signed char)(-127);
sca = (signed char)(-128); /* 2945 */
sca = (signed char)(-129); /* 2855 */
ssa = (signed short)(-32767); /* */
ssa = (signed short)(-32767 - 1); /* 2945 */
ssa = (signed short)(-32769L); /* 2855 */
sia = (signed int)(-32767); /* */
sia = (signed int)(-32767 - 1); /* 2945 */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |