![]() |
![]() |
3311 | ![]() |
||||
![]() | |||||||
| Implicitly undefined | REFERENCE - ISO:C90-6.1.2.4 Storage Durations of Objects | ||||||
A jump to this statement from a previous location in the code will result in local objects being declared but uninitialized at this point. For example, in the following code, the object 'j' appears to be initialized when it is defined, but the initialization will not actually take place if the goto statement is executed.
/*PRQA S 1-9999 ++*/
/*PRQA S 2752, 2962, 3311, 3312 --*/
extern int f1(int i, int n)
{
if (n > 0)
goto IN;
if (i)
{
int j = 2;
IN: n = j + 2; /* Message 3311 + 2962 */
goto OUT;
}
OUT: i = 2 + n;
return i;
}
extern int f2(int i, int n)
{
if (i)
{
int j = 2;
IN: n = j + 2;
goto OUT;
}
OUT: i = 2 + n;
if (n > 0)
goto IN; /* Message 3312 + 2752 */
return i;
}
MISRA C:2012 Rules applicable to message 3311:
| Rule-1.3 (Required) | There shall be no occurrence of undefined or critical unspecified behaviour |
| Rule-15.3 (Required) | Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement |
See also:
![]() | ||
| 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 |