thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Stylianou (Issue Comment Edited) (JIRA)" <j...@apache.org>
Subject [jira] [Issue Comment Edited] (THRIFT-1398) Compiler warning on generated code (Multiface kills -Wall -Werror on gcc 4.6.1)
Date Mon, 05 Mar 2012 11:47:02 GMT

    [ https://issues.apache.org/jira/browse/THRIFT-1398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13222282#comment-13222282
] 

Chris Stylianou edited comment on THRIFT-1398 at 3/5/12 11:46 AM:
------------------------------------------------------------------

Attached a patch which should resolve the issue.

Thanks to [Thomas Wiggins|https://issues.apache.org/jira/secure/ViewProfile.jspa?name=tomw]
for the peer-review!
                
      was (Author: chris5287):
    Attached a patch which should resolve the issue.

Thanks to Thomas Wiggins for the peer-review!
                  
> Compiler warning on generated code (Multiface kills -Wall -Werror on gcc 4.6.1)
> -------------------------------------------------------------------------------
>
>                 Key: THRIFT-1398
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1398
>             Project: Thrift
>          Issue Type: Bug
>          Components: C++ - Compiler
>    Affects Versions: 0.6, 0.7
>         Environment: g++ v4.6.1, with all warnings enabled -Wall, using the purist "treat
warnings as errors" -Werror flag.  No optimization flags
>            Reporter: Nevo Hed
>         Attachments: THRIFT-1398.patch
>
>
> 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 possible
lack of return
>     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]"
> IMHO we should have a single return at the end of the function
> I would add a generation-time option to suppress multiface if that seems reasonable
> At this time we find that we need to either disable the warning or up the optimization
(or both?)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message