[sv-ec] dynamic vars should be forbidden as defaults

From: danielm <danielm_at_.....>
Date: Fri Jan 18 2008 - 07:19:24 PST
LRM says that:  
1800-2005: 12.4.3 Default argument values:
"The default_value is an expression. The expression is evaluated in the
scope containing the subroutine
declaration each time a call using the default is made."
 
The problem arises when we use that rule for dynamic|automatic variables -
ie for class propeties:
class C;
  int a;
   static int b;
    function f1(int x=a);
   endfunction
    function f2(int y=this);
   endfunction
    function f3(int z = b);
   endfunction
endclass
 
IMHO only the 3rd (f3)should be allowed - because defaults are assigned
before the function call - so only statics are known at that moment.
 
 
Similar case may be also spotted in example with no classes:
module top;  
 task automatic t(int a = 1, int b = a); 
  $display(a,,b);
 endtask      
 
 initial t;
endmodule
 
 
In above case a is an automatic variable and doesn;'t exists at the moment
when defaults should be assigned.
 
DANiel

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Fri Jan 18 13:03:59 2008

This archive was generated by hypermail 2.1.8 : Fri Jan 18 2008 - 13:04:21 PST