[Issue 4534] New: Dmd crash with templates
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jul 29 16:59:45 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4534
Summary: Dmd crash with templates
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2010-07-29 16:59:44 PDT ---
This code crashes dmd 2.047 with:
Internal error: ..\ztc\cod3.c 1303
template Format(A...) {
static if (A.length == 0)
enum Format = "";
else static if (is(typeof(A[0]) : const(char)[]))
enum Format = FormatString!(A[0], A[1..$]);
}
template FormatString(const(char)[] F, A...) {
static if (F.length == 0)
enum FormatString = Format!(A);
else static if (F.length == 1)
enum FormatString = F[0] ~ Format!(A);
else static if (F[0..2] == "%s")
enum FormatString = A[0] ~ FormatString!(F[2..$], A[1..$]);
else
enum FormatString = F[0] ~ FormatString!(F[1..$], A);
}
template Tuple(T...) {
alias T Tuple;
}
enum Type : string { i1 = "x", i2 = "y", i3 = "z" }
enum Size { small = 1, medium = 2, large = 3 }
void main() {
auto types = Tuple!("a", "b", "c");
auto sizes = Tuple!("1", "2", "3");
Type run_t = Type.i1;
Size run_n = Size.medium;
enum string pattern = "if (run_t == Type.%s_type && run_n == %s && run_m ==
%s) foo!(%s, Size.%s, Size.%s)();";
foreach (t; types)
foreach (n; sizes)
foreach (m; sizes)
enum string txt = Format!(pattern, t, n, m, t, n, m);
}
Please reduce this test case if you can, or improve the bug title.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list