https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97759
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> --- As an aside, libstdc++ does already use the ((x-1) & x) == 0 idiom in <bits/uniform_int_dist.h> where we are happy for zero to be treated as a power of two (because we call _Power_of_2(n+1) and we want the result to be true for n==numeric_limits<decltype(n)>::max()). We could replace _Power_of_2(n+1) with std::__has_single_bit(n+1) || (n+1)==0 but would need to define __has_single_bit for C++11 as well as C++14.