www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000202

When Created: 01/25/1998 14:17:24
Against DJGPP version: 2.01
By whom: lsk549b@tninet.se
Abstract: Compiling programs with nested functions and -pg generates buggy code
Programs with nested functions will crash when compiled with -pg, e.g.:
----
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
   int x;

void Sub(void)
{
   printf("x=%i",x);
}

   x=random();
   Sub();
   return 0;
}
----
main() tries to pass its %ebp to Sub() in %ecx, but the call to mcount()
will destroy the register. When Sub() tries to access x, the program
will crash.

Note added: 01/27/1998 12:54:02
By whom: broeker@physik.rwth-aachen.de
This is not a DJGPP problem. It's a genuine FSF bug in gcc itself.

(gcc-2.7.2.1 on Linux has the same bug, but egcs-1.0 doesn't).

Looks like someone forgot to tell gcc that %ecx is in use during
the startup phase of a nested function

Workaround added: 01/27/1998 12:55:06
By whom: broeker@physil.rwth-aachen.de
Update gcc.

Closed on 04/12/1999 10:00:27: This is a bug in GCC 2.7.2 which is fixed in later GCC versions
By whom: eliz@is.elta.co.il



  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010