[Issue 2526] New: non-const initializer to constant accepted inside template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 20 02:00:51 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2526

           Summary: non-const initializer to constant accepted inside
                    template
           Product: D
           Version: 1.037
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: accepts-invalid, wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: kamm-removethis at incasoftware.de


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.


-- 



More information about the Digitalmars-d-bugs mailing list