[Mono-list] I think that this is a bug.

Daniel Carrera dcarrera@math.toronto.edu
Tue, 2 Apr 2002 10:20:03 -0500 (EST)


I upgraded mono but the problem persists.  Perhaps the problem is in mcs?
I have tried to upgrade mcs but I just can't make it compile.

Daniel.


On 2 Apr 2002, Dietmar Maurer wrote:

> Hi Daniel,
>
> I have tested that code with the newest CVS version of mono and it runs
> without problems here, so maybe you only need to update mono.
>
> - Dietmar
>
> On Sun, 2002-03-31 at 09:54, Daniel Carrera wrote:
> > I found a very strange behaviour in Mono.  When I make a class containing
> > a string variable, I can concatenate that string fine.  However, when the
> > class *also* has a double variable, the concatenation fails.
> >
> > Consider the following code:
> >
> > ------------------------------------------------
> >  1 class Money {
> >  2	private double Amount;
> >  3	private string Currency;
> >  4
> >  5	//public Money(double amount,string currency) {
> >  6	public Money(string currency) {
> >  7		//Amount   = amount;
> >  8		Currency = currency;
> >  9	}
> > 10	public string getCurrency() {
> > 11		return Currency;
> > 12	}
> > 13 }
> > 14
> > 15 class TestMoney {
> > 16
> > 17	public static void Main() {
> > 18		//Money m = new Money(200,"CAD");
> > 19		Money m = new Money("CAD");
> > 20		System.Console.WriteLine("Currency:  " + m.getCurrency());
> > 21	}
> > 22 }
> > ------------------------------------
> >
> > This runs fine.  However, the following does not:
> >
> > ------------------------------------
> >  1 class Money {
> >  2	private double Amount;
> >  3	private string Currency;
> >  4
> >  5	public Money(double amount,string currency) {
> >  6	//public Money(string currency) {
> >  7		Amount   = amount;
> >  8		Currency = currency;
> >  9	}
> > 10	public string getCurrency() {
> > 11		return Currency;
> > 12	}
> > 13 }
> > 14
> > 15 class TestMoney {
> > 16
> > 17	public static void Main() {
> > 18		Money m = new Money(200,"CAD");
> > 19		//Money m = new Money("CAD");
> > 20		System.Console.WriteLine("Currency:  " + m.getCurrency());
> > 21	}
> > 22 }
> > ------------------------------------
> >
> > Notice, what I've done is I've commented lines 6 and 19 and I've
> > uncommented 5, 7 and 18.
> >
> > Now I get the error:
> >
> > prompt$ mono ConcatTest.exe
> >
> > (process:6309): ** WARNING **: unhandled exception
> > System.OverflowException: "Number overflow"
> > in System.String:.ctor ()
> > in System.String:Concat ()
> > in .TestMoney:Main ()
> >
> >
> >
> > The same error occurs if "Ammount" is a float instead of a double.
> > The error *does not* occur if "Ammount" is an int.
> >
> >
> > I hope that someone can make sense out of this.
> >
> > Daniel.
> >
> >
> > _______________________________________________
> > Mono-list maillist  -  Mono-list@ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
>
>