Skip to content

lastBit not being set correctly for GDC? #21

@wilsonk

Description

@wilsonk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions