Hacker News new | past | comments | ask | show | jobs | submit login

Here's what clang does with this code (https://godbolt.org/z/Ar2qt6):

  <source>:5:11: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
  int t = x & y == z;   // ?
            ^~~~~~~~
  <source>:5:11: note: place parentheses around the '==' expression to silence this warning
  int t = x & y == z;   // ?
            ^
              (     )
  <source>:5:11: note: place parentheses around the & expression to evaluate it first
  int t = x & y == z;   // ?
            ^
          (    )
Seems like a mostly solved problem.



The problem is "mostly solved" by adding a warning to a single compiler?

Sure, there are plenty of ways to mitigate the problem. That's not the point. The point is that the problem should not have arisen in the first place to require ongoing mitigation fifty years later!


What are you going to do about it? a) just use parenthesis like everyone else, or b) turn the time back to 50 years ago and change that?

Seriously, the article was just a rant. Yeah, people 50 years ago did something wrong. So what.


My blog is about the design and implementation of programming languages; by understanding the causes of past mistakes we can learn to recognize them again today. The best mistakes to learn from are other people's!


So don’t make that kind of mistake going forward.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: