Why is this an issue?
Where multiple declarators appear in the same declaration the type of an identifier may not meet developer expectations.
Noncompliant code example
int i1; int j1; // Compliant, but not preferred
int i2, *j2; // Noncompliant
int *i3,
&j3 = i2; // Noncompliant
Compliant solution
int i1;
int j1;
int i2;
int *j2;
int *i3;
int &j3 = i2;
Resources
- MISRA C++:2008, 8-0-1 - An init-declarator-list or a member-declarator-list shall consist of a single init-declarator or member-declarator
respectively
- CERT, DCL52-J. - Do not declare more than one variable per declaration
- CERT, DCL04-C. - Do not declare more than one variable per declaration
- C++ Core
Guidelines - ES.10 - Declare one name (only) per declaration