Bug 2526 – (D1 only) non-const initializer to constant accepted inside template

Status
RESOLVED
Resolution
WONTFIX
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2008-12-20T04:00:50Z
Last change time
2019-05-11T17:01:40Z
Keywords
accepts-invalid, wrong-code
Assigned to
No Owner
Creator
Christian Kamm

Comments

Comment #0 by kamm-removethis — 2008-12-20T04:00:50Z
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.
Comment #1 by yebblies — 2012-01-29T22:22:56Z
D2 bug is duplicate of issue 2414.
Comment #2 by yebblies — 2012-01-29T22:23:06Z
*** Issue 2706 has been marked as a duplicate of this issue. ***
Comment #3 by yebblies — 2012-02-01T20:32:19Z
*** Issue 4397 has been marked as a duplicate of this issue. ***
Comment #4 by pro.mathias.lang — 2019-05-11T17:01:40Z
D1 only, works in D2