FUTURE POSTS
- Using AI agents in long-lived software projects - one day from now
- Expertise in the age of AI, or: Matt's Claude'll handle this - 3 days from now
- 15+ years of working with coding agents - 7 days from now
- Putting Claude up against our test suite - 9 days from now
- The GPU Is the New Bangalore - 11 days from now
And 1 more posts are pending...
There are posts all the way to May 05, 2026
Comments
Yay scoping braces!
Ha ha, it's quite subtle, but so obvious once you spot it.
I think there is something 'else' missing ;-)
Missing else?
LOL, I didn't saw it either
Not to mention the sheer lunacy of mid not being related to target in any discernable way. Ugh.
(oh, yeah, and missing else)
Apart from missing else, what about arithmetic overflow?
I would change the line: var mid = (left + right + 1) / 2;
to this: var mid = left + (right - left + 1) / 2;
You still get the same result, but it's a little bit safer for higher values.
The bug aside, I'd use checked((left + right + 1) / 2).
Another potential problem: behavior of comparator might be not aligned with subtraction, so that
_comparator.Compare(mid-1, mid) >=0
This is really a tricky problem to spot. :) Everyone is focused on the code inside the brackets and the missing "else" is not being observed very fast.
Sorry to dissapoint, took me a second.
Anyway, I don't belive in scoping braces when they contain 1 line, it's not safer and not easier to read.. just redundant.
Comment preview