www.digitalmars.com         C & C++   DMDScript  

D - compiler crash on template instantiation

reply "Daniel Yokomiso" <daniel_yokomiso yahoo.com.br> writes:
Hi,

    The following piece of code makes the compiler (dmd 0.48) crash on my
win2k box without any error message.


instance A(int) a;
int main() {
    printf("%d\r\n", a.id(3));
    return 0;
}
template A(T) {
    T id(T t) {
        return t;
    }
}


    As undertand I can instantiate the template before it's declaration in
the file, like creating a struct variable before the struct declaration, so
I think it's a bug of the compiler. If not an exception to the forwarding
declarations rule should be clearly stated.


    Best regards,
    Daniel Yokomiso.

"We should forget about small efficiencies, say about 97% of the time:
premature optimization is the root of all evil."
- Donald Knuth
Nov 15 2002
parent "Walter" <walter digitalmars.com> writes:
In any case, the compiler shouldn't crash! -Walter

"Daniel Yokomiso" <daniel_yokomiso yahoo.com.br> wrote in message
news:ar3n25$1sg1$1 digitaldaemon.com...
 Hi,

     The following piece of code makes the compiler (dmd 0.48) crash on my
 win2k box without any error message.


 instance A(int) a;
 int main() {
     printf("%d\r\n", a.id(3));
     return 0;
 }
 template A(T) {
     T id(T t) {
         return t;
     }
 }


     As undertand I can instantiate the template before it's declaration in
 the file, like creating a struct variable before the struct declaration,

 I think it's a bug of the compiler. If not an exception to the forwarding
 declarations rule should be clearly stated.


     Best regards,
     Daniel Yokomiso.

 "We should forget about small efficiencies, say about 97% of the time:
 premature optimization is the root of all evil."
 - Donald Knuth

Nov 15 2002