Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] indexer problem - "return has value, in function returning void"

 Even though the code was C++, but in C the failure is actually correct.

"A return statement with an expression shall not appear in a function whose return type is void. A return statement without an expression shall only appear in a function
whose return type is void."


Am 12/08/2010 20:54, schrieb Alena Laskavaia:
That is code analysis tool (codan).  I think it was fixed in 7.0.1,
you can report bug anyway, I will close it if it is fixed.

On Thu, Aug 12, 2010 at 2:41 PM, Tim Black<timblaktu@xxxxxxxxx>  wrote:
I have some void functions that return the value from other void functions,
and the indexer erroneously reports "return has value, in function returning
void" in some cases. The compiler of course is fine with this, so when I
compile, the Problem window clears. But when the indexer runs again, they
come back. This problem seems to happen only when the inner void function is
defined in another file.

So, these defs in a .h cause the error:

#include<vector>
using std::vector;
     template<class T>
     class MyVector {
       private:
         vector<int>  m_v;
       public:
         MyVector() : m_v() {}
         void push_back(T t) { return m_v.push_back(t); }  // "Return has
value, in function returning void"
     };

But this in a .h does not:

     template<class T>
     class MyClass {
         void foo() { return goo(); }
         void goo() {}
     };

And this in a .cpp does not:

void goo() { }
void foo() {
   return goo();
}

I searched bugzilla and couldn't find any corresponding issue.

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev




Back to the top