RE: [sv-bc] Question on const declaration RHS

From: Steven Sharp <sharp_at_.....>
Date: Tue Sep 23 2008 - 16:23:19 PDT
>From: "Rich, Dave" <Dave_Rich@mentor.com>

>If you take this literally, this defines what it "can" have as RHS, not
>what it "cannot" have.

If we accepted this argument, I think large portions of the language
would have to be considered to be unspecified :-)

This statement about how a static constant can be set is followed by
one saying that an automatic constant can be set to the same things
that would be legal without the const.  Clearly different rules are
being defined for the two, as they are listed as separate items, along
with value and type parameters.

It seems clear that the rules were intended to be different.  There
just isn't any reason they should be.


> I agree with mantis 2372. This sentence should be
>removed.

I agree that the restriction should be removed.

However, it is somewhat more complex than removing the sentence.  I think
the paragraph and following example should be removed.  Then the next
paragraph starting with "An automatic constant declared with the const
keyword" should be changed to say "A variable declared with the const
keyword", so that it includes both static and automatic constant variables.
I'm not sure that the LRM is entirely clear about what expressions are
allowed for initializers without const, but at least this change would
eliminate any difference specific to static const variables.

Then there is a later paragraph about const class handles that says
"The arguments to the new method must be constant expressions."  That
sentence should also be removed, for the same reasons.

BTW, the description of initializing a const object handle with new()
violates the earlier description of what is legal for initializing a
static constant, which does not include calls to new().  That may open
the door to treating this as an error in the LRM, instead of just a
useless restriction that should be removed.

Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Tue Sep 23 16:24:02 2008

This archive was generated by hypermail 2.1.8 : Tue Sep 23 2008 - 16:25:33 PDT