EndianStream needs to be reexamined!

Steven Schveighoffer schveiguy at yahoo.com
Thu Mar 27 13:54:49 PDT 2008


"Andreas Jung" wrote
> // Now call a member.
> char c;
> s.read( c ); // throws: HiddenFuncError
>
> // From the D specs:
> // " If an HiddenFuncError exception is thrown in your program,
> //   the use of overloads and overrides needs to be reexamined
> //   in the relevant classes."

This is exactly the issue I was talking about when I said that this is still 
a bad obscure bug.

http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=56594

Walter, even you cannot keep track of where this bug will bite and have 
released phobos many times without noticing!  This example has been in 
phobos for a LONG time.  This bug was added in Phobos version 0.107.

Imagine if this were a mission-critical project and the bug wasn't seen 
until something really obscure happened to cause it.  These kinds of things 
will kill D as a choice for large-scale software development.

Can we please have this bug be a compile-time error?  (Walter, I wonder if 
you could run the exercise like you did for the class != null where you 
build a compiler that flags this as a failure and see how many errors are 
found?)

BTW, the issue is that EndianStream fails to inherit the parent's read for 
1-byte types (I'm guessing the reason was that there is no need to adjust 
byte order there), so read(byte), read(ubyte), and additionally write(char), 
write(byte), and write(ubyte) should fail.

To fix this, you need to put

alias Stream.read read;
alias Stream.write write;

into EndianStream.

-Steve 





More information about the Digitalmars-d mailing list