octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

No warning for unused variables?


From: Rik
Subject: No warning for unused variables?
Date: Sat, 16 Jan 2016 17:26:23 -0800

Does anyone know of a way to check the code for unused variables?  I was
working on another task and found several instances where
"octave_value_list retval;" was completely unused, but there was no warning
during compilation.

The lack of a warning for instances of a class seems to be a problem with
gcc.  It might be different for clang or another compiler.  In any case, I
used the following test code with gcc:

--- Code ---
#include <iostream>

using namespace std;

int main()
{
   string unused_str;
   int unused_int;

   cout << "Hello World" << endl;

   return 0;
}
--- End Code ---

when compiled with

g++ -O2 -Wall -Wextra unused.cpp -o unused

the only thing I get is

unused.cpp: In function ‘int main()’:
unused.cpp:8:8: warning: unused variable ‘unused_int’ [-Wunused-variable]

It seems that the -Wunused-variable warning is only relevant for Plain Old
Datatypes.

--Rik




reply via email to

[Prev in Thread] Current Thread [Next in Thread]