amoeba icon indicating copy to clipboard operation
amoeba copied to clipboard

lastBit not being set correctly for GDC?

Open wilsonk opened this issue 2 years ago • 0 comments

Just wondering if this bit of code in util.d is correct?

/* Get the first bit set */
version (LDC) int firstBit(ulong b) {return cast (int) llvm_cttz(b, true);}
else version (GDC) alias firstBit = __builtin_ctz;
else alias firstBit = bsf;

/* Get the last bit set */
version (GDC) alias firstBit = __builtin_clz;
else alias lastBit = bsr;

The second to last line resets firstBit and doesn't actually set lastBit for GDC. Seems off to me :)

May not affect much as it seems to only be used to resize tables, but it may affect accuracy, if used in the future I suppose.

wilsonk avatar Jun 27 '23 06:06 wilsonk