Error Message

Questions and discussion about the ZBasic IDE.
Post Reply
DH*

Error Message

Post by DH* »

This code:
  • tx = tx & CStr(h)
gives this error message:
  • Internal Error: no means to generate code for expression
where tx is a string and h is a byte value. Can anyone explain what this means?

The compiler has no complaints about a few hundred earlier occurences of the same construction in the same application.
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post by mikep »

This code compiles for me:

Code: Select all

Sub main()
Dim Tx as String
Dim h as Byte
Tx = Tx & CStr(h)
End Sub
What version of the compiler are you using? The & operator is only for strings.
Mike Perks
DH*

Post by DH* »

As I said, a few hundred earlier occurences of the same construction within the same application compile OK so I'm not sure how your test relates to the issue.

I'm using Version 1.1.18 of the compiler.
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post by mikep »

dhouston wrote:As I said, a few hundred earlier occurences of the same construction within the same application compile OK so I'm not sure how your little test relates to the issue. Nor do I see how telling me that the & operator is only for strings is helpful. I've been using & only with strings since VB first introduced it.
Everyone has different skill levels and knowledge so I apologize if you think I was undervaluing your experience and skills by my response. Don may know what this error message means but it is always better to provide a testcase to duplicate the problem. My simple tescase worked so something else is needed.
Mike Perks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

Internal Error: no means to generate code for expression
Can anyone explain what this means?
Internal Errors are generally indicative of a coding error in the compiler. This particular message indicates an optimization problem. The reason that it does not occur in every other use is because the exact details that the optimizer was dealing with differ in that one case and there is either a coding or logic error in the optimizer.

To fix this type of problem, we need to have a test case that reproduces the error. The smaller the test case the easier it is to isolate the cause and correct it. We may be able to produce a test case by knowing more about the surrounding code, particularly the earlier assignments to tx and h and their later uses, if any. Also, if the statement that you showed is in some type of control construct (If, Do, For, Select, etc.) that may have a bearing on the problem.

If all you want to do is to work around the problem you can probably eliminate the error message by turning off the specific optimization called constant propagation.

Code: Select all

--optimize=no-constant-propagation
You could also use the sledge hammer approach

Code: Select all

--optimize=no-optimize
but this will also have the side effect of retaining unused code and variables.
- Don Kinzer
DH*

Post by DH* »

If I comment out the offending line, the compiler then gives me the same error message for an earlier line containing a similar construction that previously passed muster. I think the compiler needs a therapist.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

If you will send me the entirety of the source code I can probably distill from it a simplified test case. If you send it by email attachment, either put it in a .zip file or, for a single source file, rename the extension to .txt and send it to dkinzer at zbasic.net. Alternately, you could email me a URL from which I can retrieve the necessary files.
- Don Kinzer
DH*

Post by DH* »

It's in the mail.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

The cause of the problem has been identified and resolved, subject to more comprehensive testing.

In the interim, you can work around the problem by turning off constant propagation optimization by placing the option --optimize=no-constant-propagation at the top of the .pjt file. A more narrowly targeted workaround is to give the tx variable the volatile attribute.

Code: Select all

Public Volatile tx As String
The effect of this change is that it tells the optimizer to not make any assumptions about the value of the tx variable. This effectively disables constant propagation for that variable only and thus sidesteps the problem.
- Don Kinzer
DH*

Post by DH* »

Thanks for the quick response. That you accomplished it on a holiday weekend inspires awe. :shock: Have you been on this planet long?
Post Reply