Bug 321154 (MONO78416) - [GMCS] Nullable conversions
Summary: [GMCS] Nullable conversions
Status: RESOLVED FIXED
Alias: MONO78416
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Martin Baulig
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-16 14:51 UTC by Petri Latvala
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:59:03 UTC


---- Reported by adrinael@adrinael.net 2006-05-16 07:51:28 MST ----

Description of Problem:

The following little code snippet

object d;
object q;

...

q = (double?)((decimal) d);

produces an error "cannot convert from decimal to double?" on gmcs, csc
compiles it.

From the standard:

"For these reasons, no implicit conversions exist between the floating
point types and decimal"
" -- an implicit conversion exists from any non-nullable value type to a
nullable form of that type"

Strictly said, that makes (double?)decimalvalue    an error _if_ the
conversion needs to convert to double first.

gmcs seems to be correct, this is only a "differs from csc" bugreport.



---- Additional Comments From rharinath@novell.com 2006-06-15 07:28:50 MST ----

Hmm, not really.  If there's an explicit conversion from S to T,
there's an explicit nullable conversion from S to T? (Section 13.7.2
Nullable conversions)

So, a decimal -> double? explicit nullable conversion exists, which is
defined in terms of

  double -> decimal (explicit conversion)
  decimal -> decimal? (wrapping)




---- Additional Comments From martin@ximian.com 2006-06-19 18:58:11 MST ----

Fixed in SVN.


Unknown operating system unknown. Setting to default OS "Other".