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

From: Surya Pratik Saha <spsaha_at_.....>
Date: Sun Jan 27 2008 - 05:56:54 PST
Hi Dave,
I did not see anything in the LRM mentioning that restriction.

How do I impose a cast here?
Is
a[0] = byte'(b);
valid assignment then?

Also without cast, will it be a run time error or compilation time 
error. LRM does not clearly say assigning integral type to a string 
variable without cast is run time error or compilation time error. What 
is your comment on that?

Regards
Surya



-------- Original Message --------
Subject: Re:[sv-bc] Is string allowed to be assigned to any data type?
From: Rich, Dave <Dave_Rich@mentor.com>
To: Surya Pratik Saha <spsaha@cal.interrasystems.com>, sv-ec@eda.org, 
sv-bc@eda.org
Date: Saturday, January 26, 2008 11:17:43 PM
>
> 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 Sun Jan 27 05:57:47 2008

This archive was generated by hypermail 2.1.8 : Sun Jan 27 2008 - 05:59:13 PST