On Thursday, June 23, 2016 04:55:09 Tofu Ninja via Digitalmars-d-learn wrote: > On Wednesday, 22 June 2016 at 14:17:42 UTC, Jonathan M Davis > > wrote: > > Well, that particular value should probably work thanks to VRP > > (value range propagation), since 10 can fit into float with no > > loss of precision. However, what's far more disconcerting is > > that > > > > real x = real.max; > > float y = x; > > > > compiles. real to float is a narrowing conversion, which should > > be an error barring the compiler detecting that the value will > > fit in the target type even if it's a narrowing conversion > > (which only happens with VRP). That's not the sort of thing > > that I would have expected to be broken such that it begs the > > question as to whether it's intentional, but given that > > narrowing conversions without a cast are illegal everywhere > > else, this definitely seems broken. > > > > - Jonathan M Davis > > Should I make a bug report? I am not sure it's a bug, seems > intentional. Maybe a dip for a compiler flag to warn on implicit > down conversions, but it would be a pretty small dip.
You're original code is almost certainly not a bug thanks to VRP, but I would think that the example with real.max would be. So, it makes sense to me to report it. Worst case, it gets closed as invalid. I certainly wouldn't suggest a DIP for it at this point. If the bug were closed as invalid, then then a DIP might make sense (though if it were intentional, then I question that we could get Walter to change it), but I'd treat it as a bug first. - Jonathan M Davis