Possible misbehaviour due to lack of parentheses

Bug #1538500 reported by Jan Dubiec
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Hugin
Fix Released
Undecided
Unassigned

Bug Description

I do not know Hugin's code very well but fixing these warnings should be trivial for someone who does:

d:/Works/Hugin/src/hugin_base/nona/Stitcher.cpp: In function 'void HuginBase::Nona::stitchPanorama(const HuginBase::PanoramaData&, const HuginBase::PanoramaOptions&, AppBase::ProgressDisplay*, const string&, const UIntSet&, const AdvancedOptions&)':
d:/Works/Hugin/src/hugin_base/nona/Stitcher.cpp:97:38: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         if (bands == 1 || bands == 2 && extraBands == 1) {
                                      ^
d:/Works/Hugin/src/hugin_base/nona/Stitcher.cpp:99:45: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         } else if (bands == 3 || bands == 4 && extraBands == 1) {
                                             ^
d:/Works/Hugin/src/hugin_base/nona/Stitcher.cpp:107:38: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         if (bands == 1 || bands == 2 && extraBands == 1) {
                                      ^
d:/Works/Hugin/src/hugin_base/nona/Stitcher.cpp:116:45: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         } else if (bands == 3 || bands == 4 && extraBands == 1) {

=============================================================================

d:/Works/Hugin/src/hugin_base/panodata/Panorama.cpp: In member function 'bool HuginBase::PanoramaMemento::loadPTScript(std::istream&, int&, const string&)':
d:/Works/Hugin/src/hugin_base/panodata/Panorama.cpp:2949:45: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
             if (iImgInfo[i].links[*v] == -2 && oImgInfo[i].links[*v] != -2 || iImgInfo[i].links[*v] == -1 && oImgInfo[i].links[*v] >=0) {

=============================================================================

d:/Works/Hugin/src/tools/cpclean.cpp: In function 'int main(int, char**)':
d:/Works/Hugin/src/tools/cpclean.cpp:243:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses]
     if(!onlyPair)
       ^

Jan Dubiec (jdx)
description: updated
Revision history for this message
tmodes (tmodes) wrote :

Only one of the mentioned warnings is true. The other ones are false positive: && has higher precedence then ||. So the expressions are correct c++.
Nevertheless I added parentheses to improve readability.

Changed in hugin:
status: New → Fix Committed
tmodes (tmodes)
Changed in hugin:
milestone: none → 2016.0rc1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.