I now did fresh

cd teTeX-1.0/texk/kpathsea
mkdir a-b-c
cp -a kpsewhich a-b-c

and got

./a-b-c/kpsewhich -expand-var='$SELFAUTODIR'

So I now try to isolate the problem.  First off, simple optimization
`-O' is no problem; the problem occurs only with `-O2'. 

I created the try2.c found at 


It is basically texk/kpathsea/xdirname.c and texk/kpathsea/xmalloc.c,
but I changed the TEST ifdef to 

#ifdef TEST

char *tab[] = {

int main()
  char **p;
  for (p = tab; *p; p++)
    printf("name %s, dirname %s\n", *p, xdirname(*p));
  return 0;
#endif /* TEST */

Putting try2.c in the top teTeX source directory, teTeX-1.0/, I do

# cc -g -O2 -Wall -I./texk  -DTEST try2.c
# ./a.out 
name /p/q/a-b-c/kpsewhich, dirname /p/q/a-b-c
name /p/q/a-b-c, dirname /p/q/a-b
name /p/q/a-b, dirname /p/q/a

So the ouch is already here. All is well, if I replace `-O2' by `-O':

# cc -g -O -Wall -I./texk  -DTEST try2.c
# ./a.out 
name /p/q/a-b-c/kpsewhich, dirname /p/q/a-b-c
name /p/q/a-b-c, dirname /p/q
name /p/q/a-b, dirname /p/q

I would try to isolate further but 

1) For my untrained eyes, it is rather discouraging to see function
   definitions via macros

   xmalloc P1C(unsigned, size)  
   xdirname P1C(const_string, name)

2) Perhaps somebody knowing the code could easily point out the real

My only idea at this point would be to create and look at the assembly

Perhaps one should collect the necessary defines from the .h files
into a single one, and send it along with try2.c to the gcc
developers so that they have a standalone test suite. 


Reply via email to