issue-#128 Assignment of named empty string to SHORTCHARs

Post Reply
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

issue-#128 Assignment of named empty string to SHORTCHARs

Post by Josef Templ »

I have noticed that assignment of a named empty string constant to a variable of type
ARRAY OF SHORTCHAR does not work. Also in 1.6.
For the issue see http://redmine.blackboxframework.org/issues/128.

Here is a test program that fails:

Code: Select all

MODULE Test;

CONST NamedEmptyStr = "";

PROCEDURE Do*;
	VAR s: ARRAY 30 OF SHORTCHAR;
BEGIN
	s := NamedEmptyStr;
	ASSERT(s[0] = 0X, 99);
END Do;

END Test.
This reminds me of Robert's question: Will it ever end?

- Josef
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#128 Assignment of named empty string to SHORTCHAR

Post by Josef Templ »

Here is the diff of my proposal for a fix:

http://redmine.blackboxframework.org/pr ... c73e8746c7

This fix is in the front-end where there is an optimization for an assignment of an empty stirng.
It is converted into s[0] := 0X and the conversion had a bug. It did not clear the original constant object of the string.
Therefore it was used by the code generator instead of the value 0.

- Josef
luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

Re: issue-#128 Assignment of named empty string to SHORTCHAR

Post by luowy »

Josef Templ wrote:Here is the diff of my proposal for a fix:

http://redmine.blackboxframework.org/pr ... c73e8746c7

This fix is in the front-end where there is an optimization for an assignment of an empty stirng.
It is converted into s[0] := 0X and the conversion had a bug. It did not clear the original constant object of the string.
Therefore it was used by the code generator instead of the value 0.

- Josef
yes,very well.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: issue-#128 Assignment of named empty string to SHORTCHAR

Post by Josef Templ »

This issue is ready for voting, I think.

- Josef
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: issue-#128 Assignment of named empty string to SHORTCHAR

Post by Robert »

Josef Templ wrote:This reminds me of Robert's question: Will it ever end?
This reminds me of Chris' answer: "No"
Post Reply