[Mono-list] Re: Strange compiler (mis)behaviour

Robert Jordan robertj@gmx.net
Wed, 23 Feb 2005 08:27:59 +0100


Aleksandar Dezelin wrote:

> This is the problematic piece of code:
> 
> template.CompressionLevel is of type short.
> template.CompressionLevel = (reader.IsDBNull(1)) ? 0 : reader.GetInt16(1);
> 
> why mcs compiler does not generate code like in the case the second line is:
> 
> template.CompressionLevel = (reader.IsDBNull(1)) ? (short)0 :
> reader.GetInt16(1);

It's by design. See ECMA-334-C# 14.12.

bye
Rob