That's SQL:99 6.22 <cast specification> general rule 11) c). (SV and TD are the source value and the target datatype for a cast.)
In hindsight, it would likely be more consistent with this if we'd considered bitstrings to be LSB first when coercing them to/from integer, but whoever stuck that behavior in didn't think about it. Too late to change that now I'm afraid, though perhaps we could provide non-cast conversion functions that act that way.
Apologies, I was under the impression that casts were not in the spec. I withdraw my request. In the 2016-draft it reads,
> If the length in octets M of SV is smaller than LTD, then TV is SV extended on the right by
LTD–M X'00's.
That's how I read it too, and whether I feel like it's insane doesn't matter much. But yet, the idea
5:bit(8)::bit(32)::int
Not being 5 is terrifying, so you won't find any objections to the current behavior from me.