Code::Blocks Forums
Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: frithjofh on December 02, 2015, 01:11:56 pm
-
just a small path cleaning up a conditio in the line of
!A || (A && B)
is really the same as
!A || B
-
Beware of this construct. There are no precedence rules for logical operations so the compiler can choose to make
!A || B && C
into
!(A || B&&C)
or
(!A) || B && C
Been bitten by this myself before... It looks like compilers even take a space into account and treat it differently if there is a space between the ! and A or not.
Yves
-
the standard does give precedence rules for logical operators...
it states clearly that the logical not is of higher precedence than && and this higher than ||
it would have to be a bad implementation of the compiler
and remark the parenthesis too. they are like that in the code. this is not about left tor right or right to left ordering...
but, heck, maybe I am wrong ... I'll stand corrected gladly
thx for the feedback
-
Of course there are precedence rules in C++ also there is early exit in conditionals.
http://en.cppreference.com/w/cpp/language/operator_precedence
-
The patch is in trunk now, thanks.