g++ -vs Java boolean

Per Bothner per@bothner.com
Wed Aug 4 21:30:00 GMT 1999


Mark Mitchell <mark@codesourcery.com> writes:

> >>>>> "Per" == Per Bothner <per@bothner.com> writes:
> Well, for instance, are `int' and `jint' "compatible types" if they
> happen to have the same length on a given platform?  It seems that you
> imply below that they are compatible.  (For example, you can't
> overload them separately.)

Not quite.  It's more that I see no use for being able to overload
them separately.

> It sounds like you're saying that `jint' and `T' are the same type
> (where `T' is the right-sized C++ type), except that `jint' things get
> mangled differently from `T' things.

No.  Obviously they are not the same type if they mangle differently.

> Does `jshort' promote to `jint' or to `int'?

Any reason if can't be:  Yes (to both).

> Is `jboolean' like bool in that the only well-defined values are zero
> and one?  At present, it's like char, so `jboolean jb = 7' is
> presumably not the same as `jboolean jb = true.'  Is that the right
> thing?

jboolean should have the same TYPE_CODE as bool.

Perhaps the cleanest solution would be to consider the relationship
between jint and int like the relationship between int and long
(on a 32-bit system).  That suggests that __java_int etc are new
unique types, just like long.  I believe wchar_t is treated the same way.

That does imply that you could be able to define foo(int) and foo(jint)
at the same time, which would imply they must be mangled differently.
That is OK.  We could have the demangler translate the jint mangling
to "jint" when in C++ mode and "int" when given the Java flag.  We
would have to define new manglings code - and the Java manglings would
probably be longer.

Or we could just mangle "jint" and "int" the same, even if we consider
them to be different types.  That would dis-allow overloading foo(jint)
and foo(int) - which might be a good thing.  
-- 
	--Per Bothner
bothner@pacbell.net  per@bothner.com   http://home.pacbell.net/bothner/


More information about the Gcc-bugs mailing list