Spent half the afternoon tracking down a mysterious segfault
caused by
one little line:
static char *sort_phen1 = NULL,*sort_phen2 = NULL;
static int initialised = FALSE;
/* lots of code */
static int sort_comp_phen(Ind *s1, Ind *s2)
{
char *sort_phen1,*sort_phen2;
if (!initialised){
sort_phen1 = chrom_string();
sort_phen2 = chrom_string();
initialised = TRUE;
}
strcpy(sort_phen1,chrom_phenotype(s1->chrom));
strcpy(sort_phen2,chrom_phenotype(s2->chrom));
return strcmp(sort_phen1,sort_phen2);
}
Strange how you can never see something that's staring you in
the face. Compiling with the -Wshadow flag
would've caught it.