Actually, the C++ compiler cannot catch such errors. You could only avoid such mistakes artificially. Therefore, I suggest that you increase the warning level to avoid this error as much as possible by setting Properties->C/C++->General->Warning Level
.
For this question, you could modify the code:
void DoNothing(const int&){}
//Or
void DoNothing(int){}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…