digitalmars.D.bugs - [Issue 12625] New: implicit slicing of RValue static array should be
- via Digitalmars-d-bugs (30/30) Apr 23 2014 https://issues.dlang.org/show_bug.cgi?id=12625
https://issues.dlang.org/show_bug.cgi?id=12625 Issue ID: 12625 Summary: implicit slicing of RValue static array should be illegal Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: monarchdodra gmail.com This will compile without a single warning: //---- int[1] foo(); int[] a = foo(); //---- It's wrong, because we are obtaining a slice to temporary data. This isn't even a question of escape analysis or anything like that. It's really just nothing more than (basically) taking the address of a temporary, which is pretty much wrong 100% of the time, and never correct. I've been hit by it several times. I've fixed and seen the bug in phobos. It's come up regularly in phobos learn. Without entirelly putting into question the implicit slicing of static arrays, can we *please* at least patch this specific use case? The *only* code this *can* break (and *will* break) is code that is certifiably worng. --
Apr 23 2014