This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PR c++/33887] Fix incorrect use of jboolean in link.cc
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Fri, 18 Jan 2008 17:09:48 -0200
- Subject: [PR c++/33887] Fix incorrect use of jboolean in link.cc
We've been lucky for a while, because C++ doesn't reduce types
narrower than registers to their native width after every operation,
or ever. This enabled jboolean to behave like an unsigned byte,
rather than like a single bit, in the use in link.cc.
As we experimented transitioning C++ to a reduce-after-every-operation
mode, as a possible fix for PR c++/33887, this thinko in libjava got
exposed, because, with the change, the jboolean gets truncated to a
single bit. So, when a superclass has an even number of interfaces,
it remains unchanged, and when two superclasses both have odd numbers
of interfaces, they cancel out. Oops.
Fixed with the patch below, that Tom Tromey pre-approved. I'll check
it in as soon as my re-testing is completed.
for libjava/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR c++/33887
* link.cc (_Jv_Linker::prepare_constant_time_tables):
has_interfaces is boolean, treat it as such.
Index: libjava/link.cc
===================================================================
--- libjava/link.cc.orig 2007-07-31 18:46:36.000000000 -0300
+++ libjava/link.cc 2008-01-18 16:49:13.000000000 -0200
@@ -1,6 +1,7 @@
// link.cc - Code for linking and resolving classes and pool entries.
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ Free Software Foundation
This file is part of libgcj.
@@ -662,10 +663,11 @@ _Jv_Linker::prepare_constant_time_tables
// interfaces or primitive types.
jclass klass0 = klass;
- jboolean has_interfaces = 0;
+ jboolean has_interfaces = false;
while (klass0 != &java::lang::Object::class$)
{
- has_interfaces += klass0->interface_count;
+ if (klass0->interface_count)
+ has_interfaces = true;
klass0 = klass0->superclass;
klass->depth++;
}
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}