digitalmars.D.bugs - problem with inheritance of FilterStream
- bayo (34/34) Dec 30 2007 Hello.
- Derek Parnell (21/28) Dec 30 2007 This is the problem. It is using the wrong 'printf'. The code below work...
- Derek Parnell (22/22) Dec 30 2007 Actually, if I was doing this I'd write it more like ...
- bayo (4/7) Dec 31 2007 Thanks a lot for your help Derek. I think i will do it now,
Hello. Iv got a problem today i never seen befor. Maybe its the first time i inherite a phobos class, i realy dont know. When i create instance of Foo, the printf (maybe) generate an "Error: Access Violation". If i remove all printf of the class (my real class is not this simple example) it run (but its hard to debug). To "patch" this problem i remove the FilterStream inheritance, but i use the same interface (without a real interface). I can do it for the moment, but its not fine at all. I have this problem with dmd 1.013 (win), i update to 1.015 and its the same. I compile with -unittest, i test without this option, and it change nothing. I spend long time to understand the problem, is anybody see it? import std.stream; class Foo : FilterStream { this (Stream stream) { printf("foo\n"); // Error: Access Violation super(stream); } } class Foo2 { Stream source; this (Stream stream) { printf("foo2\n"); // No problem source = stream; } } unittest { printf("begin\n"); new Foo(null); printf("end\n"); } Thanks a lot for your help. --bayo
Dec 30 2007
On Sun, 30 Dec 2007 17:52:41 +0100, bayo wrote:Hello. Iv got a problem today i never seen befor. Maybe its the first time i inherite a phobos class, i realy dont know. When i create instance of Foo, the printf (maybe) generate an "Error: Access Violation".This is the problem. It is using the wrong 'printf'. The code below works. import std.stream; import std.stdio; class Foo : FilterStream { this (Stream stream) { std.stdio.printf("foo\n"); super(stream); } } unittest { printf("begin\n"); new Foo(null); printf("end\n"); } -- Derek Parnell Melbourne, Australia skype: derek.j.parnell
Dec 30 2007
Actually, if I was doing this I'd write it more like ... import std.stream; import std.stdio : dbg = writefln; class Foo : FilterStream { this (Stream stream) { debug dbg("foo"); super(stream); } } unittest { debug dbg("begin"); new Foo(null); debug dbg("end"); } void main(){} -- Derek (skype: derek.j.parnell) Melbourne, Australia 31/12/2007 9:16:36 AM
Dec 30 2007
Derek Parnell a écrit :Actually, if I was doing this I'd write it more like ... [...]Thanks a lot for your help Derek. I think i will do it now, it an easily method to prevent this king of error. --bayo
Dec 31 2007