std.format and uninitialized elements in CTFE

berni44 dlang at d-ecke.de
Mon Dec 9 06:10:43 UTC 2019


On Sunday, 8 December 2019 at 20:18:23 UTC, Steven Schveighoffer 
wrote:
> It definitely is the cast(const). Removing it works. And it 
> makes sense -- a const type cannot be a range, as popFront can 
> never be const.

Nit-picking: A infinite range producing always the same item 
could be....

> So one thing you CAN do, in cases like this is just initialize 
> the damn void stuff in CTFE.

Hmm. Feels a little bit like healing symptoms. We would need to 
identify all such places in Phobos. I'm not sure, if this is, 
what I'd like to see. (And it doesn't fix Ali's examples.) But I 
havn't got a better idea yet.

> const(ToCapitalizerImpl)(const(Result)(const(ByCodeUnitImpl)("test"), 4294967295), const(ToCaserImpl)(const(Result)(const(ByCodeUnitImpl)(""), 4294967295), 0, "\0\0\0"), false, "\0\0\0", 0)

Indeed, not really, what one wants to have...

> Which is going to result in a *different* confusion. Even if it 
> said "<void>" like you want, it's still a pile of gibberish 
> that's far from what you expect.

So, what would we expect? Ideally, it would note, that it's not a 
good idea to make a range const. But I think, that neither the 
compiler (does not know about ranges) nor Phobos (may not even be 
called) can do that.

Yet I've got no clue, what's best here...


More information about the Digitalmars-d mailing list