https://issues.dlang.org/show_bug.cgi?id=12625
Steven Schveighoffer <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] Severity|normal |enhancement --- Comment #7 from Steven Schveighoffer <[email protected]> --- This came up in the newsgroup: (https://forum.dlang.org/post/[email protected]) I think we can say safely that slicing an rvalue return cannot lead to anything good. As for the example of why it should be allowed, I'm not convinced. That example requires blind faith that the receiver of the slice never does anything bad with it, and assumes the compiler doesn't cleverly reclaim the memory for the rvalue seeing as it wasn't used anywhere. We should reject it for the same reason we reject fun(&generateSomeInt()). Sure, fun may not do anything bad, but it has a lot of leeway to do so. Not sure how to up the importance of this. Note, let's not confuse this issue with slicing of a static array that has dedicated stack space (i.e. not a temporary). That may also be rendered an error somehow, but this is vastly more erroneous. --
