[previous] 0456 [next] [C] This expression does not have an address - '&' may only be applied to an lvalue or a function designator.
Constraint violations REFERENCE - ISO:C90-6.3.3.2 Address and Indirection Operators - Constraints

This is a constraint error

The address-of operator & can only be applied to a function designator or an lvalue that designates an object that is not a bit-field and is not declared with the register storage-class specifier. For example:


/*PRQA S 2211,3198,3199,3203,3408,3447,3635,3672 ++*/

extern int g;
extern void func(int x);

void foo(void)
{
    int *pi;
    void (*pvf)(int x);

    pi = &g;           /* Operand of & is an lvalue              */
    pvf = &func;       /* Operand of & is a function designator  */
    pvf = func;        /* & is optional on a function designator */ /* See ISO-C90 6.2.2.1 */

    pi = &(g + 1);     /* Message 0456                           */
}


MISRA C:2012 Rules applicable to message 0456:

Rule-1.1  (Required) The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits


QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents