This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Internal compiler error while compiling Moonlight Creator (1.0.3a)
- To: egcs-bugs at cygnus dot com
- Subject: [PATCH] Internal compiler error while compiling Moonlight Creator (1.0.3a)
- From: Michael Poole <poole+ at andrew dot cmu dot edu>
- Date: Thu, 11 Jun 1998 01:39:30 -0400
I noticed several people last month complained about g++ dying
while compiling Moonlight Creator, and didn't see a solution in the
list archives. I've found the reason for this, and provided a
suggested patch and test case. It only occurs when compiling with
-falias-check, since it depends on a function being mis-identified as
a malloc-type function and this identification is only done when alias
checking is enabled. This bug is present in egcs-1.0.2-release and
egcs-1.0.3a; I don't know about more recent versions of the compiler.
What happens is that a class in ml (Moonlight Creator)
implements a realloc method that returns a bool. calls.c:expand_call
interprets this as a malloc-type function. valreg is 0 (apparently
due to the return value being ignored by the caller, although I'm not
100% sure that is why), but the handling around line 1993 assumes that
valreg is non-null. My patch assumes that a constraint that the
return value from a malloc/calloc/realloc invocation not being void is
sufficient to assume that the returned value is not an alias for
anything else.
++ voidmalloc.cpp (testcase for g++ -falias-check) ++
class A {
public:
void malloc(void) { return; }
};
int main(int argc, char *argv[]) {
A a;
a.malloc();
return 0;
}
Tue Jun 11 01:38:44 1998 Michael Poole (poole+@andrew.cmu.edu)
* calls.c (expand_call): A void expression cannot be the
result of a malloc-type function call.
--- gcc/calls.c.orig Mon Aug 11 16:07:08 1997
+++ gcc/calls.c Thu Jun 11 01:15:56 1998
@@ -887,7 +887,8 @@
else if (flag_alias_check
&& ((tname[0] == 'm' && ! strcmp(tname + 1, "alloc"))
|| (tname[0] == 'c' && ! strcmp(tname + 1, "alloc"))
- || (tname[0] == 'r' && ! strcmp(tname + 1, "ealloc"))))
+ || (tname[0] == 'r' && ! strcmp(tname + 1, "ealloc")))
+ && TYPE_MODE (TREE_TYPE (exp)) != VOIDmode)
is_malloc = 1;
}