www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12625] New: implicit slicing of RValue static array should be


          Issue ID: 12625
           Summary: implicit slicing of RValue static array should be
           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

Apr 23 2014