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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3792 - Regression(1.053) "non-constant expression" for a template inside a struct using a struct initializer
Summary: Regression(1.053) "non-constant expression" for a template inside a struct us...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other All
: P2 regression
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2010年02月11日 05:08 UTC by Fawzi Mohamed
Modified: 2014年02月15日 02:28 UTC (History)
3 users (show)

See Also:


Attachments
a testcase that fails (1.86 KB, text/d-source)
2010年02月11日 06:51 UTC, Fawzi Mohamed
Details
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Fawzi Mohamed 2010年02月11日 05:08:09 UTC
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 Fawzi Mohamed 2010年02月11日 06:51:50 UTC
Created attachment 566 [details] 
a testcase that fails
Comment 2 Matti Niemenmaa 2010年02月11日 08:55:10 UTC
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 Fawzi Mohamed 2010年03月08日 00:27:59 UTC
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 Walter Bright 2010年03月08日 22:24:37 UTC
Fixed dmd 1.057
Comment 5 Fawzi Mohamed 2010年03月09日 03:24:39 UTC
As I wrote in my previous comment, the attached testcase still fails...
Comment 6 Don 2010年05月31日 06:11:36 UTC
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 Don 2010年06月24日 13:55:11 UTC
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 9 Don 2011年05月30日 07:58:57 UTC
Fixed DMD2.053


AltStyle によって変換されたページ (->オリジナル) /