[Mono-dev] CS0019 for value type != null

Casey Marshall cmarshall at pacificbiosciences.com
Mon Apr 7 20:16:05 EDT 2008


I've noticed that on a recent SVN build of mono, I get a CS0019 error if
I try to compare a value type against null. E.g.:

  DateTime dt;
  if (dt != null)
    Console.WriteLine(dt);

As far as I can tell, this is the correct behavior, since a value type
can't be null. I'm concerned, though, because this behavior seems to
have been introduced recently in SVN, AND it looks like MS's compiler
doesn't reject this statement (well, I haven't seen it accept it, but
this is existing code which apparently compiles fine under Visual
Studio).

So, my question is, what's going on here? Does anyone know what the
semantics are if the compiler generates a conditional based on a
`valuetype CMP null' test?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080407/cb6a9503/attachment-0001.html 


More information about the Mono-devel-list mailing list