Bug 398 – No way to abort compilation in a doubly recursive mixin
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-10-04T04:46:00Z
Last change time
2014-02-15T13:20:32Z
Assigned to
bugzilla
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2006-10-04T04:46:45Z
This program generates 2^16 local variables called 'val'. Oops. But the problem is, the compiler hangs. It would be better if ^C worked, or even if it just segfaulted! But probably, there just needs to be some check on number of local variables.
(BTW, it's *really* cool that this code actually works for smaller numbers of w, eg rubbish!(10).)
---------
template rubbish(int w)
{
static if (w<=0) {
int val = 2;
} else {
mixin rubbish!(w-1) left;
mixin rubbish!(w-1) right;
}
}
void main()
{
mixin rubbish!(15);
}
Comment #1 by thomas-dloop — 2006-10-06T02:10:36Z
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email protected] schrieb am 2006-10-04:
> http://d.puremagic.com/issues/show_bug.cgi?id=398
> This program generates 2^16 local variables called 'val'. Oops. But the problem
> is, the compiler hangs. It would be better if ^C worked, or even if it just
> segfaulted! But probably, there just needs to be some check on number of local
> variables.
>
> (BTW, it's *really* cool that this code actually works for smaller numbers of
> w, eg rubbish!(10).)
>
> ---------
> template rubbish(int w)
> {
> static if (w<=0) {
> int val = 2;
> } else {
> mixin rubbish!(w-1) left;
> mixin rubbish!(w-1) right;
> }
> }
>
> void main()
> {
> mixin rubbish!(15);
> }
Added to DStress as
http://dstress.kuehne.cn/run/m/mixin_25_A.dhttp://dstress.kuehne.cn/nocompile/m/mixin_25_B.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFFJgXvLK5blCcjpWoRAotVAJ9X0CWuInG+4dJDIkD/9OIb7Td9KQCfeXlp
kSi+etI2JTZkT2e1amaKjVQ=
=VrRy
-----END PGP SIGNATURE-----