RE: [sv-ec] constant expression in call to new

From: Rich, Dave <Dave_Rich_at_.....>
Date: Wed Nov 15 2006 - 13:32:40 PST
Arturo,

 

Then the restriction should have been on static class construction, not
on const class construction. A const class handle could be static or
automatic. There are no ordering problems with automatic const variable
construction. I would prefer a note in the LRM to warn the users about
order of evaluation problems with static variable initializations rather
than to overly restrict the arguments to new.

 

My example could have any PLI routine or even a PLI override of
$test$plusargs, which is executed by call to its calltf routine. That
routine sets the return value as part of the variable declaration
initialization. 

 

Dave

 

 

________________________________

From: Arturo Salz [mailto:Arturo.Salz@synopsys.com] 
Sent: Wednesday, November 15, 2006 10:29 AM
To: Rich, Dave; sv-ec@eda-stds.org
Subject: RE: [sv-ec] constant expression in call to new 

 

Dave,

 

That statement was there mainly to avoid ordering and race problems
associated with declaration 

initializations, which, as you point out exist with other declarations.
However, the severity of an 

ordering problem with static class declarations is worse than for other
(static) declarations because

accessing un-initialized objects have no defined behavior and will
likely cause a crash. Because 

these declarations execute outside the procedural context, such problems
are very hard to debug.

A secondary goal was to attempt to keep implementations from deviating.
Otherwise, the LRM would 

have to mandate an explicit ordering; something that was too ambitious
at the time.

 

Interestingly, the expression used by your example is not constant, but
will behaves like a constant 

because its value is set even before variable declarations.

 

            Arturo

 

________________________________

From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
Rich, Dave
Sent: Wednesday, November 15, 2006 8:29 AM
To: sv-ec@eda-stds.org
Subject: [sv-ec] constant expression in call to new 

 

Section 6.3.5 about const constants says "The arguments to the new
method must be constant expressions."

 

Can anybody think of a reason why we need this rule? Why single out new
from any other function call? 

 

Any variable declaration initialization, const or non-const will have
problems if you reference other variables.

 

 

The reason I ask is I would like to be able to do things like

 

const classname foo= new($test$plusargs("switch"));

 

Dave

 
Received on Wed Nov 15 13:32:50 2006

This archive was generated by hypermail 2.1.8 : Wed Nov 15 2006 - 13:33:06 PST