Re: strange warning with -Wparentheses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/13/2010 04:18 AM, andre maute wrote:
Consider the following code

-------ambiguouselse.cc---------
#include <iostream>
int main() {
int n;
std::cout << "Enter number: ";
std::cin >> n;
if( n > 10 )
if( n > 20 ) {
std::cout << "A" << std::endl;
} else {
std::cout << "B" << std::endl;
}
return 0;
}
-------ambiguouselse.cc---------

$> g++ -Wparentheses ambiguouselse.cc
ambiguouselse.cc: In function ‘int main()’:
ambiguouselse.cc:12:4: warning: suggest explicit braces to avoid ambiguous ‘else’

---------------------------------

I don't understand the warning here, the situation here is
different as in the documentation for -Wparentheses.

sorry, the spaces got lost, but is ambiguous the correct
wording here? it doesn't result in undefined behavior.
the else couples always with the inner if

i misinterpreted the documentation for -Wparentheses

So never mind and regards
Andre



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux