[Sablevm-developer] gcc bug or not?
Brought to you by:
egagnon
From: David <db...@cs...> - 2004-03-06 21:19:23
|
Hi, I have this code structure in sablevm.c and it was seg faulting on OS X/ppc and I noticed recently that it segfaults also on Linux/x86 but not Linux/ppc. This occurs when SableVM is not compiled with debugging code. case ARG_JIT_OPTION: { const char *str =3D NULL; int len; if (...) { ... } else if (strncmp (argument, str =3D "intr-count=3D", len =3D strlen (str)) =3D=3D 0) = { ... } else { ... } It segfaults in strlen. The reg containing str on x86 was containing NUL= L. So either the evaluation order of the arguments in C is undefined (gcc gives no warning for that code) and that the 3rd arg is computed before the 2nd arg or there is a bug in gcc such that gcc cannot compute the dependency and reverse them. This occurs only in non-debugging mode. Any suggestion/comments from C and gcc experts? I will work around it by changing the code structure. My gcc versions are: x86: 3.3.3 20040110 (prerelease) (Debian) OS X/ppc: gcc (GCC) 3.1 20020420 (prerelease) Linux/ppc: gcc-3.3 (GCC) 3.3.2 (Debian) David --- David B=E9langer Graduate Student School of Computer Science McGill University Office: MC226 Web page: http://www.cs.mcgill.ca/~dbelan2/ Public key: http://www.cs.mcgill.ca/~dbelan2/public_key.txt |