This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to fix PR9861
On 27 Sep 2005 10:18:05 -0600, Tom Tromey <tromey@redhat.com> wrote:
> >>>>> "TJ" == TJ Laurenzo <tlaurenzo@gmail.com> writes:
>
> >> Also, constructors have no encoded return type. I guess that's OK,
> >> but I was rather surprised.
>
> TJ> The decision to exclude return types on constructors was based on a
> TJ> list of C++ rules for excluding return types for members of template
> TJ> classes.
>
> It is weird, but valid, to have a method with the class' name in java.
> Would we get a symbol clash for a class like this?
>
> public class Weird {
> public Weird (int x) { /* constructor */ }
> public int Weird() { return 5; /* method */ }
> }
>
> Tom
>
No. The mangled forms would be as follows:
public Weird(int x) : _ZN5WeirdC1Ei
public int Weird() : _ZN5Weird5WeirdEJiv
The actual name of the constructor is not included in the mangled
form and the extra "J" qualifier further distinguishes it from a
regular method.
You learn something new every day. I had never even considered that
you could have methods with the same name as the class. Guess I slept
through that part of the JLS.
TJ