RE: [sv-bc] Is string allowed to be assigned to any data type?

From: Rich, Dave <Dave_Rich_at_.....>
Date: Sat Jan 26 2008 - 09:47:43 PST
A single element of a string is a byte, which is an integral type. It's
not legal to assign a string to an integral type without a cast.

 

With a cast, b would have to be exactly one character, or you will get a
run time error.

 

Dave

 

 

________________________________

From: owner-sv-bc@server.eda.org [mailto:owner-sv-bc@server.eda.org] On
Behalf Of Surya Pratik Saha
Sent: Saturday, January 26, 2008 4:21 AM
To: sv-ec@server.eda.org; sv-bc@server.eda.org
Subject: [sv-bc] Is string allowed to be assigned to any data type?

 

Hi,
As per SV 1800 LRM:
A string or a string literal can be assigned directly to a string
variable. Integral types can be assigned to a string variable, but
require a cast.

This imposes some restriction when LHS of an assignment is a string
type. But is any data type allowed to be LHS when RHS is a string. I did
not see anything in the LRM, though following e.g. is marked as illegal:
string b = ""; 
string a = {"Hi", b};
a[0] = b; // invalid, requires a cast

It is not at all clear why the assignment is invalid, how it can be made
valid by casting on which side. Most of the simulators pass the case
though. Is there any mantis or clarification for that?



-- 
Regards
Surya

-- 
This message has been scanned for viruses and 
dangerous content by MailScanner <http://www.mailscanner.info/> , and is

believed to be clean. 

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Sat Jan 26 09:48:16 2008

This archive was generated by hypermail 2.1.8 : Sat Jan 26 2008 - 09:51:02 PST