There is bunch of inconsitency and unclerance after mantis 1384 fix LRM draft 6 : 6.24.1 Description of static cast: "If the expression is assignment compatible with the casting type, then the cast shall return the value that a variable of the casting type would hold after being assigned the expression. If the expression is not assignment compatible with the casting type, then if the casting type is an enumerated type, the behavior shall be as described as in 6.19.4, and if the casting type is a bit-stream type, the behavior shall be as described in 6.24.3." The sentence is still open - what should happened if dest and source is not assignment compatybile and casting type is not an enum not bit-stream type - is it possible? What about classes - are they bit stream - is not so obvious 6.24.3: "An associative array type or class shall be illegal as a destination type." (this was allowed in 1800-2005 now draft 6 bans it) Both above are contradictory - becaue 1st allows to cast to a type which is assignment compatybile (which is possible for class handles - ie cast to super class) while 2nd forbids static cast to class type. IMHO there are two solutions : - cast to class should be fdisallowed in all cases - sentence from 6.24.3 should be moved to 6.24.1 - cast between class handles should be allowed - it should not perform any kind of check on compile/elab time - but on run time it should triggger fatal errors if casted types are not compatybile - this should be described in 6.24.3. Cast where source is a non-class bit stream class and dectination is a class handle should be forbidden in 6.24.3 as an addition an example - what should be the behaviour of tool in below example class B; reg x; function f(); $display("B",x); endfunction endclass class A extends B; int y; function f(); $display("B",y); endfunctionendclass module top; A a; B b; initial begin b = 'B(a); /// should it be legal?? this is ok according to 6.24.1 but offends 6.24.3 a = 'A(b); /// should it be legal?? this offends both : 6.24.1 and 6.24.3 'B(a).f(); /// should it be legal?? this show the only sensible usage of casting to base class type but is this ok according to syntax??? end endmodule DANiel -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Wed Sep 10 04:55:57 2008
This archive was generated by hypermail 2.1.8 : Wed Sep 10 2008 - 04:56:42 PDT