digitalmars.D.learn - Using immutable values as template parameter hangs dmd
- simendsjo (14/14) Jun 26 2011 This is probably not a minimal test case, but it's as far as I got.
- Simen Kjaeraas (13/27) Jun 26 2011 It's a case of infinite recursive templates. My dmd fails after
This is probably not a minimal test case, but it's as far as I got. Don't know what the actual bug is, so I'd be grateful if someone else could help explain it so I can add it to Bugzilla with a better subject. This is using DMD 2.053 on win7. struct S(int N) { immutable SN = N; // Using N instead, and the compiler doesn't hang // It doesn't have anything to do with alias. The same occurs in method templates etc. alias S!SN T; } void main() { S!(4) s; }
Jun 26 2011
On Sun, 26 Jun 2011 16:10:04 +0200, simendsjo <simen.endsjo pandavre.com> wrote:This is probably not a minimal test case, but it's as far as I got. Don't know what the actual bug is, so I'd be grateful if someone else could help explain it so I can add it to Bugzilla with a better subject. This is using DMD 2.053 on win7. struct S(int N) { immutable SN = N; // Using N instead, and the compiler doesn't hang // It doesn't have anything to do with alias. The same occurs in method templates etc. alias S!SN T; } void main() { S!(4) s; }It's a case of infinite recursive templates. My dmd fails after a few seconds with Error: out of memory, right after semantic3. Same bug also occurs with const values. Think I understand what's going on now - the alias tries to instantiate the template with an immutable int, dmd says 'hey, that's implicitly convertable to a normal int', and instantiates the template. Now, that template does not know it is in fact instantiated with an immutable int, and thus feels S!SN is something different from S!N, and creates a whole new instantiation when it gets to the alias line. GOTO 10. -- Simen
Jun 26 2011