Bug 2229 – ICE(template.c) instantiating an invalid variadic template with more than one argument
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-07-16T03:56:00Z
Last change time
2014-03-01T00:37:03Z
Keywords
diagnostic, ice-on-invalid-code, patch
Assigned to
nobody
Creator
samukha
Comments
Comment #0 by samukha — 2008-07-16T03:56:41Z
T foo(A...)()
{
return "";
}
void main()
{
foo!(1, 2)(); // crashes when there is more than one parameter
}
Comment #1 by smjg — 2008-07-16T05:25:20Z
Please remember to assign keywords to bug reports. To everybody reading this: Please look through issues you've reported and check for missing keywords.
Also, please avoid vague summary lines that could equally apply to many unrelated bugs. As a guide, if there exists a keyword that says what your summary says, then the summary is too vague.
Comment #2 by samukha — 2008-07-16T06:30:40Z
Ok. Could the bugzilla ugliness be modified so that there is a combo from which to select keywords? I keep forgetting their spelling.
I have changed the summary because the compiler crashes when the template is parametrized with any tuple containing more than one element.
Comment #3 by samukha — 2008-07-16T06:32:18Z
*** Bug 2230 has been marked as a duplicate of this bug. ***
Comment #4 by smjg — 2008-07-17T11:58:32Z
(In reply to comment #2)
> Ok. Could the bugzilla ugliness be modified so that there is a combo from which
> to select keywords? I keep forgetting their spelling.
Really, a <select multiple> is what we want. I don't know whether there's an option in Bugzilla to do this, but it could probably be done by hacking the local installation. That said, the version of Bugzilla we're using here is far from current, so FAIK the best COA might be to upgrade.
Comment #5 by dsimcha — 2009-01-09T14:20:24Z
*** Bug 2435 has been marked as a duplicate of this bug. ***
Comment #6 by clugdbug — 2009-01-14T00:50:53Z
Again, I note that this applies to D1.x as well
Test case from the closed bug 2345.
---
Foo foo(A...)()
{
}
static assert(foo!(1, 2)());
Comment #7 by clugdbug — 2009-04-03T07:11:56Z
*** Bug 2566 has been marked as a duplicate of this bug. ***
Comment #8 by clugdbug — 2009-04-03T07:15:51Z
No longer segfaults.
---------
DMD 1.042:
Assertion failure: 'i < parameters->dim' on line 806 in file 'template.c'
abnormal program termination
-------
DMD2.027:
bug.d(1): Error: template fog.foo(A...) declaration A is already defined
which seems incorrect.
Comment #9 by clugdbug — 2009-04-03T08:13:23Z
*** Bug 2555 has been marked as a duplicate of this bug. ***
Comment #10 by clugdbug — 2009-09-12T11:50:02Z
This is actually really simple.
ROOT CAUSE: The D1 logic in template.c, TemplateDeclaration::deduceFunctionTemplateMatch() is completely wrong.
if (nargsi > parameters->dim) && tp, the assert in the for loop will definitely fail.
PATCH (around line 797 of template.c):
==========
if (targsi)
{ // Set initial template arguments
nargsi = targsi->dim;
+ size_t argsToUse = nargsi;
if (nargsi > parameters->dim)
{ if (!tp)
goto Lnomatch;
dedargs->setDim(nargsi);
dedargs->zero();
+ argsToUse = parameters->dim;
}
memcpy(dedargs->data, targsi->data, nargsi * sizeof(*dedargs->data));
- for (size_t i = 0; i < nargsi; i++)
+ for (size_t i = 0; i < argsToUse; i++)
{ assert(i < parameters->dim);
This patch also fixes bug 1897.
Comment #11 by bugzilla — 2009-10-13T13:51:09Z
Fixed dmd 1.049
Comment #12 by clugdbug — 2009-11-07T14:51:08Z
The patch for this bug was incorrectly transcribed.
template.c, line 807.
- memcpy(dedargs->data, targsi->data, n * sizeof(*dedargs->data));
+ memcpy(dedargs->data, targsi->data, nargsi * sizeof(*dedargs->data));
This is causing dstress case for bug 1144 to fail.
http://dstress.kuehne.cn/nocmpile/m/mixin_34_A.d
Comment #13 by clugdbug — 2009-11-07T22:43:31Z
*** Issue 3482 has been marked as a duplicate of this issue. ***