[previous] 0755 [next] [C] 'return' expression is not of arithmetic type.
Constraint violations REFERENCE - ISO:C90-6.6.6.4 The return Statement - Semantics, ISO:C90-6.3.16.1 Simple Assignment - Constraints

This is a constraint error

This function has been declared with a return type which is arithmetic but the return expression is not of arithmetic type - maybe it's a pointer or a 'struct' or a 'union'.

For example:


/*PRQA S 750,759,2006,2213,2216,3120,3132,3210,3205,3227,3408,3447,3623,3625 ++ */

struct ST1 { int si; char sbuf[10];};
union  UN1 { int ui; int uj;};

extern struct ST1 st1a;
extern union  UN1 un1a;

extern int *pi;
extern int **ppi;

extern int foo(int mode)
{
    if      (mode ==  0)
    {
        return(pi);                                /* Message 0755 */
    }
    else if (mode ==  1)
    {
        return(ppi);                               /* Message 0755 */
    }
    else if (mode ==  2)
    {
        return(st1a);                              /* Message 0755 */
    }
    else if (mode ==  3)
    {
        return(un1a);                              /* Message 0755 */
    }
    else
    {
        return(1);                                 /*              */
    }

}


MISRA C:2012 Rules applicable to message 0755:

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