Summary: non-const initializer to constant accepted inside
           Product: D
           Version: 1.037
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: accepts-invalid, wrong-code
          Severity: major
          Priority: P2
         Component: DMD

This compiles and fails the assert:

template T() { const o = new Object; }
void main() { assert(T!().o is T!().o); }

It should not compile, as
const o = new Object;
also fails with "Error: non-constant expression new Object".

The assert is triggered because DMD emits a call to new for each mention of
T!().o inside a function.


Reply via email to