digitalmars.D.bugs - [Issue 4534] New: Dmd crash with templates
- d-bugmail puremagic.com (52/52) Jul 29 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4534
- d-bugmail puremagic.com (11/11) Aug 29 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4534
- d-bugmail puremagic.com (11/11) Aug 29 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4534
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 puremagic.com
ReportedBy: bearophile_hugs eml.cc
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: -------
Jul 29 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4534
Andrej Mitrovic <andrej.mitrovich gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |andrej.mitrovich gmail.com
19:00:50 PDT ---
On 2.047 it causes that error, but on 2.048 it seems to be gone. I don't know
how to close bug reports so you'll have to do it. :)
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4534
bearophile_hugs eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
You are right, thank you very much. So I close this bug.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 29 2010









d-bugmail puremagic.com 