c++compilation

Why should "unreferenced formal parameter" worry me?


What is the reason for issuing "unreferenced formal parameter" warning? In an existing SO post this warning is explained to be useful for drawing the attention of the programmer to the function (in case he forgot to do some operations with the parameter) and also useful for code maintenance (to signal to future developers that the parameter was not omitted, but was purposely left out). Apart from style concerns, why does the programmer want to be warned against unused parameters? Are such parameters copied, if passed by value?

void myFunction(int param) {
}

Solution

  • To prevent possible distractions (forgetting to use the parameter) and to strive for a more maintainable code are reasons enough.

    The possible performance hit of unused parameters being copied is an additional reason, but not the main one.