This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Downcasting
- To: Fabrice Medio <fmedio at mandrakesoft dot com>
- Subject: Re: Downcasting
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Mon, 25 Jun 2001 16:37:31 -0700 (PDT)
- Cc: java at gcc dot gnu dot org
- References: <h2hex4z0dn.fsf@spinlock.mandrakesoft.com>
- Reply-To: apbianco at cygnus dot com
Fabrice Medio writes:
> ~/tmp$ gcj -C -Wall Foobar.java
> ~/tmp$
>
> Is this a bug or a feature ?
It's an ancient feature.
It's happening in gcc/java/decl.c:build_result_decl and I think was
introduced for better cooperation with C++ when CNI was hacked on, in
order to fix an early bug (I say `think' because I can't find the
matching ChangeLog entry, `cvs log' doesn't help either:)
tree
build_result_decl (fndecl)
tree fndecl;
{
tree restype = TREE_TYPE (TREE_TYPE (fndecl));
/* To be compatible with C_PROMOTING_INTEGER_TYPE_P in cc1/cc1plus. */
if (INTEGRAL_TYPE_P (restype)
&& TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
restype = integer_type_node;
...
We should find a way to be able to report this problem, regardless of
what is done for the sake of compiler cooperations. It's obviously
wrong for jc1 not to report this error (note that when the assignment
is checked, it's too late for jc1 to realize that something's wrong.)
I'm going to file a PR. Thanks!
./A