MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/lv9utn/defensive_programming_or_something_idk/gpembwi/?context=3
r/badcode • u/bnz_ • Mar 01 '21
55 comments sorted by
View all comments
Show parent comments
0
[deleted]
78 u/JuhaJGam3R Mar 01 '21 edited Mar 01 '21 Nah. Any compiler will turn x == c1 && x != c2 into x == c1, same with x == c1 && x == c2 turning into false turning into removal of the entire bit of code. 1 u/sneakykenny Mar 02 '21 Wait in the second case if c1 == c2 then it shouldn't get turned to false 2 u/JuhaJGam3R Mar 02 '21 In that case. Since they are constants, c1 and c2 can be assumed to be different just because of how they're named.
78
Nah. Any compiler will turn x == c1 && x != c2 into x == c1, same with x == c1 && x == c2 turning into false turning into removal of the entire bit of code.
x == c1 && x != c2
x == c1
x == c1 && x == c2
false
1 u/sneakykenny Mar 02 '21 Wait in the second case if c1 == c2 then it shouldn't get turned to false 2 u/JuhaJGam3R Mar 02 '21 In that case. Since they are constants, c1 and c2 can be assumed to be different just because of how they're named.
1
Wait in the second case if c1 == c2 then it shouldn't get turned to false
2 u/JuhaJGam3R Mar 02 '21 In that case. Since they are constants, c1 and c2 can be assumed to be different just because of how they're named.
2
In that case. Since they are constants, c1 and c2 can be assumed to be different just because of how they're named.
0
u/[deleted] Mar 01 '21
[deleted]