![]() |
![]() |
1337 | ![]() |
||||
![]() | |||||||
| Functions | |||||||
Functions with variable number of parameters are problematic because the number and types of parameters are not known to the compiler, so no type checking can be performed on the ellipsis arguments. Moreover, default argument promotion will be performed on these arguments, which may generate unexpected results, e.g. when a composite expression is passed. For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 1337 --*/
void foo (int a, ...)
{
/* ... */
}
void f1337 (short b, unsigned char c)
{
foo (0, b); // 2nd argument is converted to int
foo (0, c); // 2nd argument is converted to int
foo (0, c << 4); // 2nd argument may be greater than 256
}
MISRA-C:2004 Rules applicable to message 1337:
| Rule 16.1 (Required) | Functions shall not be defined with a variable number of arguments. |
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |