[Issue 8530] New: Float types default initializers doesn't work in class

Daniel Kozak kozzi11 at gmail.com
Fri Aug 10 02:30:33 PDT 2012


On Friday, 10 August 2012 at 09:27:25 UTC, Daniel Kozak wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=8530
>
>            Summary: Float types default initializers doesn't 
> work in class
>            Product: D
>            Version: D2
>           Platform: x86_64
>         OS/Version: Linux
>             Status: NEW
>           Severity: major
>           Priority: P2
>          Component: DMD
>         AssignedTo: nobody at puremagic.com
>         ReportedBy: kozzi11 at gmail.com
>
>
> --- Comment #0 from Daniel Kozak <kozzi11 at gmail.com> 2012-08-10 
> 02:27:21 PDT ---
> Created an attachment (id=1136)
> problematic code
>
> When I create class with some float variable without value, 
> then call some
> method on this class and test float variable for default value, 
> it doesnt work.
>
> My code is in in attachment

Problematic code:
-----------------------------------------------------------
module main;

import std.stdio;

class A {
	private float floatInClass;
	
	public void tryfloatInitValue() {
		float floatInLocalScope;
		
		if (floatInClass is float.init) {
			writeln("floatInClass OK");
		} else {
			writeln("floatInClass ERR");
		}
		
		if (floatInLocalScope is float.init) {
			writeln("floatInLocalScope OK");
		} else {
			writeln("floatInLocalScope ERR");
		}
	}
}

void main(string[] args)
{
	A smth = new A();
	smth.tryfloatInitValue();
}

----------------------------------------------------------
Same for double, but for real type it is ok




More information about the Digitalmars-d-bugs mailing list