1

with this simple code

#include <stdexcept>

int main() {

  try {
  } catch (const std::runtime_error& anError) {
  }

} 

neither g++-4.9 nor clang++-3.5 with the -Wextra flag enabled (required for other unreferenced local variable issues notification) detect anything wrong, while reportedly Visual Studio correctly issues a C4101 warning (I do not own a vs toolchain, so I can't confirm this).

This is an issue since my static analysis tool, configured with a sufficiently high level of aggressiveness, reports these uses as problems. I would rather solve them at source-code level, instead of impacting my static analysis tool effectiveness.

Is anyone aware of a way to get those warning from those two compilers as well?

Thanks!

Blazor
  • 171
  • 4
  • 11
  • Maybe this article helps: http://stackoverflow.com/questions/1486904/how-do-i-best-silence-a-warning-about-unused-variables Its the contrary of your problem. – jotrocken Nov 20 '14 at 10:32
  • @jotrocken I would use that technique to silence the warnings if only I had them in the first place. Regretfully, in the current situation I have to wait for my static analysis tool outcome to know where I have to intervene. Thanks! – Blazor Nov 20 '14 at 14:55

1 Answers1

-1

You can simply write:

try {
} catch (const std::runtime_error&) {
}
Buddy
  • 10,874
  • 5
  • 41
  • 58
  • Thanks for the answer, but this is not what I asked. I would like those compilers to warn me about that named variable not being used in the catch body: if I knew about its existence in the first place, I would not need the compiler at all! – Blazor Nov 10 '17 at 09:52