On Fri, 2012-04-13 at 16:50 +0200, Bernd Schmidt wrote: > On 04/13/2012 04:44 PM, Jakub Jelinek wrote: > > On Fri, Apr 13, 2012 at 04:33:17PM +0200, Bernd Schmidt wrote: > >> On 04/13/2012 04:20 PM, Mike Stump wrote: > >>> On Apr 13, 2012, at 5:30 AM, NightStrike wrote: > >>>>> no warning from trunk. Which GCC version emits this warning? > >>> > >>>> Looks like cygwin gcc 3.4.4 > >>> > >>> 3.4.4 is a little old now.. We'd encourage an upgrade to a fine new > >>> compiler... :-) > >> > >> The thing is, the else really is ambiguous, so it looks like we have a > >> warning regression. > > > > To the compiler? There is for in between, no need to put extra braces IMHO. > > I believe it has been intentionally fixed for 4.0, but my bisect tree only > > goes back to r90000. > > Well, to the compiler even > if () > if () > x > else > y > > has an unambiguous meaning. The problem is that a human might be > confused, for example due to bad indentation.
For me this warning is almost always a false positive since I am unable to turn it of selectively. I am programming in C++. My main use of if () ; else y is to get a temporary scope that doesn't have any braces, e.g. in this macro #define DEBUG if (!enable_debugging) ; else debug_object() where debug_object is an instance of std::ostream. I then use it like DEBUG << "fancy message goes here"; Now, writing if (condition) DEBUG << "ooops, condition is true"; is not that far-fetched and obviously triggers the warning but I have a hard time seeing how that is confusing to a casual reader of the code. (In order to avoid this warning I am currently writing the above code as #define DEBUG switch (!enable_debugging) case false: debug_object() but that makes the define harder to understand and so the net result of the warning is to reduce the clarity of the code) /MF