www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2526] New: non-const initializer to constant accepted inside template

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: kamm-removethis 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.


-- 
Dec 20 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2526



--- Comment #1 from yebblies <yebblies gmail.com> 2012-01-30 17:22:56 EST ---
D2 bug is duplicate of issue 2414.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 29 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2526


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tomas famolsen.dk


--- Comment #2 from yebblies <yebblies gmail.com> 2012-01-30 17:23:06 EST ---
*** Issue 2706 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 29 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2526


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfxjfg gmail.com


--- Comment #3 from yebblies <yebblies gmail.com> 2012-02-02 15:32:19 EST ---
*** Issue 4397 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 01 2012