When compiling the following file with g++ 4.3.0, with -Wall :

---- main.cpp ----
struct foo {
  bool a;
  volatile bool b,c;  // removing 'volatile' here removes the warning.
  foo() { a = b = c = false; }
};

int main() {
  foo A;
}
-- end of main.cpp --

-bash-3.00$ g++ main.cpp -Wall

tata.cpp: In constructor 'foo::foo()':
tata.cpp:4: warning: suggest parentheses around assignment used as truth value

It seems that having an assignement between 'volatile' and non-volatile bools
activates the warning. I don't see any reason why it should behave like this.
Removing the volatile keyword (or adding it in the line above) removes the
warning.


-- 
           Summary: Strange "warning: suggest parentheses around assignment
                    used as truth value" with volatile/non volatile bools
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: David dot Tschumperle at greyc dot ensicaen dot fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36069

  • [Bug c++/36069] New: S... David dot Tschumperle at greyc dot ensicaen dot fr

Reply via email to