![]() |
![]() |
0673 | ![]() |
||||
![]() | |||||||
| Constraint violations | REFERENCE - ISO:C90-6.5.7 Initialization - Semantics, ISO:C90-6.3.16.1 Simple Assignment - Constraints | ||||||
This is a constraint error A pointer has been initialized with an expression which points to a more heavily qualified type. ISO:C requires that the type pointed to by the initialised object must have all the qualifiers of the type pointed to by the initializer. It is therefore not permissible to initialize an object of type "TYPE *" (pointer to TYPE) with an expression of type "const TYPE *" (pointer to const TYPE) or "volatile TYPE *" (pointer to volatile TYPE); to do so would permit type qualification restrictions to be violated. On the other hand, it is perfectly legitimate to initialize an object of type "const TYPE *" or "volatile TYPE *" or even "const volatile TYPE *" with an expression of type "TYPE *". For example:
/*PRQA S 3205,3210,3408,3447,3602 ++ */
extern int *gpi;
extern const int *gpci;
extern volatile int *gpvi;
extern const volatile int *gpcvi;
void test(void)
{
int *xpia = gpi; /* */
int *xpib = gpci; /* Message 0673 */
int *xpic = gpvi; /* Message 0673 */
int *xpid = gpcvi; /* Message 0673 */
const int *xpcia = gpi; /* */
const int *xpcib = gpci; /* */
const int *xpcic = gpvi; /* Message 0673 */
const int *xpcid = gpcvi; /* Message 0673 */
volatile int *xpvia = gpi; /* */
volatile int *xpvib = gpci; /* Message 0673 */
volatile int *xpvic = gpvi; /* */
volatile int *xpvid = gpcvi; /* Message 0673 */
const volatile int *xpcvia = gpi; /* */
const volatile int *xpcvib = gpci; /* */
const volatile int *xpcvic = gpvi; /* */
const volatile int *xpcvid = gpcvi; /* */
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |