You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Nevo Hed <nh...@bamboom.com> on 2011/10/14 04:06:19 UTC

Generated multiface code causes compiler warning: control reaches end of non-void function

This was generated with a fresh copy of 0.7.0 using the tutorial.thrift

I use an older version of g++ (4.1.2) but some of my fellow team members who
are using a more recent version (4.6.1)
they are reporting that (when used with '-Wall') g++, justifiably complains
about the second


  int32_t calculate(const int32_t logid, const Work& w) {
    size_t sz = ifaces_.size();
    for (size_t i = 0; i < sz; ++i) {
      if (i == sz - 1) {
        return ifaces_[i]->calculate(logid, w);
      } else {
        ifaces_[i]->calculate(logid, w);
      }
    }
  }


Though a human reading this code can see that the last
loop execution results in a return, the compiler can't
     "error: control reaches end of non-void function [-Werror=return-type]"

I did not see anything in JIRA for this, should I create an issue for this?
(reluctant to address it myself because I'm not a user of Multiface and I
would not know if its fixed)

I would add a generation-time option to suppress multiface if that seems
reasonable

Thanks
   -Nevo


p.s. We like to compile with -Wall -Werror, and would rather not disable any
warnings ... hence this simple looking issue, is an issue for us.