[Issue 17351] Static const array can't be evaluated at compile time when passed as ref argument
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Tue Sep  4 19:15:53 UTC 2018
    
    
  
https://issues.dlang.org/show_bug.cgi?id=17351
kinke at gmx.net changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke at gmx.net
--- Comment #10 from kinke at gmx.net ---
I seem to have come across a variant of this as well. This works since v2.067:
int f1(ref const int p)    { return p; }
int f2(ref const int[2] p) { return p[0] + p[1]; }
void main()
{
    static immutable int[2] P = [ 0, 1 ];
    static assert(f1(P[0]) == 0);
    static assert(f2(P) == 1);
}
But only if there's the first static assert (!). Comment that out, and it'll
complain about 'static variable `P` cannot be read at compile time'. See
https://run.dlang.io/is/uyWPmm.
--
    
    
More information about the Digitalmars-d-bugs
mailing list