Bug 5703 – std.intrinsic. and core.bitop.bsf, bsr and bswap should be CTFE-able

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-03-05T06:20:00Z
Last change time
2011-10-08T17:54:33Z
Assigned to
nobody
Creator
kennytm

Comments

Comment #0 by kennytm — 2011-03-05T06:20:20Z
import core.bitop; enum x = bsf(0b111100); enum y = bsr(0b111100); enum z = bswap(0b111100); static assert(x == 2); static assert(y == 5); static assert(z == 0x3C000000); The three functions bsr, bsf and bswap are pure nothrow, but cannot be used in CTFE because there is no source code. These functions should be rewritten in D like bitswap and popcnt.
Comment #1 by bearophile_hugs — 2011-03-05T10:34:00Z
(In reply to comment #0) > These functions should be rewritten in D like bitswap and popcnt. I think they aren't functions.
Comment #2 by kennytm — 2011-03-05T13:34:17Z
(In reply to comment #1) > (In reply to comment #0) > > > These functions should be rewritten in D like bitswap and popcnt. > > I think they aren't functions. They appear to be functions, and can easily implemented as functions too. If they are special-cased in the compiler, I see no reason they can't be recognized in CTFE as well.
Comment #3 by bugzilla — 2011-10-08T17:54:33Z