www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Template crashes DMD 0.149

reply Kramer <Kramer_member pathlink.com> writes:
Issues with the code that follows.

1) Both "if" statements in the foreach in main crash DMD.  They can be commented
in any way as long as they're not commented together and they'll crash.

2) If you uncomment the "exists" function declaration (that is currently
commented) and comment the one below it, DMD will crash.

I could just be using templates incorrectly here, but in either case, it's a bug
that DMD crashes.

I'm using Win2k, DMD 0.149.

:void main() {
:    char[][] result, test;
:    
:    foreach (x; test) {
:        if (exists!(char[][], char[])(result, x) == true) {
:            return true;
:        }
:        if (exists(result, x) == true) {
:            return true;
:        }
:    }
:}

:template exists(T, U) {
:    //bool exists(T[][] src, U[] test) {
:    bool exists(T src, U test) {
:        foreach (x; src) {
:            if (x == test) {
:                return true;
:            }
:        }
:        
:        return false;
:    }
:}

-Kramer
Mar 09 2006
next sibling parent "Walter Bright" <newshound digitalmars.com> writes:
This problem appears to be another manifestation to a previous one I've got 
fixed now. 
Mar 09 2006
prev sibling parent reply Brad Roberts <braddr puremagic.com> writes:
On Thu, 9 Mar 2006, Kramer wrote:

 Issues with the code that follows.
 
 1) Both "if" statements in the foreach in main crash DMD.  They can be
commented
 in any way as long as they're not commented together and they'll crash.
 
 2) If you uncomment the "exists" function declaration (that is currently
 commented) and comment the one below it, DMD will crash.
 
 I could just be using templates incorrectly here, but in either case, it's a
bug
 that DMD crashes.
 
 I'm using Win2k, DMD 0.149.
 
 :void main() {
 :    char[][] result, test;
 :    
 :    foreach (x; test) {
 :        if (exists!(char[][], char[])(result, x) == true) {
 :            return true;
 :        }
 :        if (exists(result, x) == true) {
 :            return true;
 :        }
 :    }
 :}
 
 :template exists(T, U) {
 :    //bool exists(T[][] src, U[] test) {
 :    bool exists(T src, U test) {
 :        foreach (x; src) {
 :            if (x == test) {
 :                return true;
 :            }
 :        }
 :        
 :        return false;
 :    }
 :}
 
 -Kramer

filed as bug #38.
Mar 12 2006
parent Kramer <Kramer_member pathlink.com> writes:
In article <Pine.LNX.4.64.0603121054590.30259 bellevue.puremagic.com>, Brad
Roberts says...
On Thu, 9 Mar 2006, Kramer wrote:

 Issues with the code that follows.
 
 1) Both "if" statements in the foreach in main crash DMD.  They can be
commented
 in any way as long as they're not commented together and they'll crash.
 
 2) If you uncomment the "exists" function declaration (that is currently
 commented) and comment the one below it, DMD will crash.
 
 I could just be using templates incorrectly here, but in either case, it's a
bug
 that DMD crashes.
 
 I'm using Win2k, DMD 0.149.
 
 :void main() {
 :    char[][] result, test;
 :    
 :    foreach (x; test) {
 :        if (exists!(char[][], char[])(result, x) == true) {
 :            return true;
 :        }
 :        if (exists(result, x) == true) {
 :            return true;
 :        }
 :    }
 :}
 
 :template exists(T, U) {
 :    //bool exists(T[][] src, U[] test) {
 :    bool exists(T src, U test) {
 :        foreach (x; src) {
 :            if (x == test) {
 :                return true;
 :            }
 :        }
 :        
 :        return false;
 :    }
 :}
 
 -Kramer

filed as bug #38.

Thanks Brad. I'll be sure to use the bug tracker next time. :P
Mar 12 2006