D - A bug in the Comparison of dynamic structure arrays
- Matthew B. (21/21) Oct 19 2003 Unless I'm missing some nuance of the syntax, it seems that the linker f...
- Marcel Strik (5/36) Oct 21 2003 I might be wrong, but I think this is the right behaviour.
- Walter (5/11) Jan 26 2004 fails
Unless I'm missing some nuance of the syntax, it seems that the linker fails when one tries to compare arrays of structures. Here is the code fragment that will generate the linker error struct sowhat { uint failure ; } int main(char[][] args) { sowhat[] s1, s2 ; int k ; s1.length = 3 ; s2.length = 3 ; for (k = 0 ; k < s1.length ; k++) { s1[k].failure = 1 ; s2[k].failure = 1 ; } // If we loop through each element of the array and check we are OK for (k = 0 ; k < s1.length ; k++) assert(s1[k] == s2[k]) ; // A direct comparison like below doesn't work assert(s1 == s2) ; return(0) ; }
Oct 19 2003
I might be wrong, but I think this is the right behaviour. I think assert(s1 == s2); will compare the addresses of s1 and s2 which will be different. assert(s1[] == s2[]); might work, but I'm not sure. "Matthew B." <mattcbro earthlink.net> wrote in news:bmv3lg$2r0q$1 digitaldaemon.com:Unless I'm missing some nuance of the syntax, it seems that the linker fails when one tries to compare arrays of structures. Here is the code fragment that will generate the linker error struct sowhat { uint failure ; } int main(char[][] args) { sowhat[] s1, s2 ; int k ; s1.length = 3 ; s2.length = 3 ; for (k = 0 ; k < s1.length ; k++) { s1[k].failure = 1 ; s2[k].failure = 1 ; } // If we loop through each element of the array and check we are OK for (k = 0 ; k < s1.length ; k++) assert(s1[k] == s2[k]) ; // A direct comparison like below doesn't work assert(s1 == s2) ; return(0) ; }
Oct 21 2003
"Matthew B." <mattcbro earthlink.net> wrote in message news:bmv3lg$2r0q$1 digitaldaemon.com...Unless I'm missing some nuance of the syntax, it seems that the linkerfailswhen one tries to compare arrays of structures. Here is the code fragment that will generate the linker error struct sowhat { uint failure ; }To make it work, there needs to be a Typeinfo created for sowhat. Right now, it would need to be done manually.
Jan 26 2004