Bug 3792 – Regression(1.053) "non-constant expression" for a template inside a struct using a struct initializer

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
All
Creation time
2010-02-11T05:08:00Z
Last change time
2014-02-15T02:28:28Z
Keywords
rejects-valid
Assigned to
nobody
Creator
fawzi

Attachments

IDFilenameSummaryContent-TypeSize
566Fixed.da testcase that failstext/d-source1900

Comments

Comment #0 by fawzi — 2010-02-11T05:08:09Z
The conversions of scalars to Fixed type now fails at compile time. There are several similar bugs to which it might be connected. I join a reduced tango and xf independent test case. Possibly connected to this xf.omg.core.CoordSys (that includes LinearAlgebra) segfaults.
Comment #1 by fawzi — 2010-02-11T06:51:50Z
Created attachment 566 a testcase that fails
Comment #2 by matti.niemenmaa+dbugzilla — 2010-02-11T08:55:10Z
Reduced: struct S { int x; template T(int val) { const S T = { val }; } } const x = S.T!(0); // arst.d(9): Error: non-constant expression (S).T
Comment #3 by fawzi — 2010-03-08T00:27:59Z
This bug is listed as fixed in 1.057, but while the reduced case by Matti Niemenmaa is indeed fixed, the original testcase still fails (I am pointing it out so that it stays open...)
Comment #4 by bugzilla — 2010-03-08T22:24:37Z
Fixed dmd 1.057
Comment #5 by fawzi — 2010-03-09T03:24:39Z
As I wrote in my previous comment, the attached testcase still fails...
Comment #6 by clugdbug — 2010-05-31T06:11:36Z
Reduced test case for the case that still fails. It's the same, except that the struct member is explicitly named in the struct initializer. struct S { int x; template T(int val) { const S T = { x: val }; } } const x = S.T!(0);
Comment #7 by clugdbug — 2010-06-24T13:55:11Z
The D2 version of this code never compiled without error. struct S { int x; template T(int val) { enum S T = { x: val }; } } const x = S.T!(0); It fails to compile because init.c, StructInitializer::toExpression() returns NULL if any of the fields have names ( if (field.data[i]) goto Lno; ) And this is just because it's never been implemented.
Comment #8 by bugzilla — 2011-04-23T15:50:37Z
Comment #9 by clugdbug — 2011-05-30T07:58:57Z
Fixed DMD2.053