| Thread overview | |||||||
|---|---|---|---|---|---|---|---|
|
July 13, 2011 Uninitialized floating-point exceptions -> optional compile-time warnings? | ||||
|---|---|---|---|---|
| ||||
I'm wondering about this:
void main()
{
import std.math;
FloatingPointControl fpc;
fpc.enableExceptions(FloatingPointControl.severeExceptions);
float foo;
}
Declaring uninitialized floating point variables after enabling severe
exceptions will throw at runtime:
object.Error: Invalid Floating Point Operation
I don't know whether this is intentional or not, if it is then:
Why not make this an optional compile-time warning as well? The compiler is smart enough to figure out that foo was declared uninitialized. Perhaps we could add another switch for this purpose.
I'm running into a lot of these uninitialized floating-point issues lately, and that's exactly why I'm using FloatingPointControl. However this is only useful at runtime. If the compiler can catch some of these at compile-time via some optional switch that would make the situation much better.
| ||||
July 13, 2011 Re: Uninitialized floating-point exceptions -> optional compile-time | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | Andrej Mitrovic:
> I don't know whether this is intentional or not,
I think it was not intentional. Regarding your successive questions, Don is your man and best hope.
Bye,
bearophile
| |||
July 13, 2011 Re: Uninitialized floating-point exceptions -> optional compile-time | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile | I think he's on a vacation though. :p | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply