std.digest toHexString

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 16 10:47:34 PDT 2017


On Thu, Mar 16, 2017 at 10:40:51AM -0700, H. S. Teoh via Digitalmars-d-learn wrote:
[...]
> Is implicit slicing the culprit in the issue I just filed? (Bug 17261)
> 
> In retrospect, perhaps implicit casting to immutable is OK if we don't
> allow implicit slicing:
> 
> 	char[32] func() { char[32] s; return s; }
> 	string gunk() {
> 		string x = func(); // error, if implicit slicing is not allowed

Actually, the bug still exists even if you explicitly slice it:

	string x = func()[]; // still compiles, but shouldn't

For some reason, slicing a static array return value is somehow OK,
while slicing a local variable is rejected.  Seems like the compiler is
missing escaping ref checks for return values?


T

-- 
People tell me I'm stubborn, but I refuse to accept it!


More information about the Digitalmars-d-learn mailing list