breese / trial.protocol

Network wire protocols
11 stars 4 forks source link

Fix weird issue #64

Closed vinipsmaker closed 1 year ago

vinipsmaker commented 1 year ago

The tests were breaking on my project when I upgraded to C++20. I was able to narrow down the problem, but I'm not sure what should be the proper fix here.

Trial.Protocol's <bit.hpp> defines countl_zero() to call __builtin_ctz(). Upon reading documentation on __builtin_ctz(), I find:

Returns the number of trailing 0-bits in x, starting at the least significant bit position.

According to C++20's <bit>, that's not countl_zero(), but countr_zero(). By applying this PR, my tests pass again. Should I rename Trial.Protocol's countl_zero() to countr_zero() as well, or just keep this one-line change? What should be the name of the commit?

breese commented 1 year ago

Your analysis is correct.

I have renamed the function in 79149f604a49b8dfec57857ca28aaf508069b669.

While reproducing this, I also encounter a few other C++20 issues, so I fixed this one as well.