Page 1 of 1
Internal error on compile
Posted: 11 February 2008, 12:08 PM
by victorf
While compiling the program WindReader.bas, I received the following error message:
Internal error: expression.cpp(3207), Rev 881: unexpected binary operator, "WindReader.bas" line 358
These are lines 357 and 358:
Code: Select all
xproj = cos(DegToRad(90.0 - sensordata.azimuth)) _
* (height / tan(DegToRad(sensordata.elevation))) 'meters
Where the local variable xproj is defined:
Code: Select all
Dim xproj as Single
Dim height as Single
And global variable sensordata is of this type:
Code: Select all
Structure SensorDataType
Public azimuth as Single
Public elevation as Single
Public roll as Single
End Structure
What does the message mean? Are errors of this kind documented somewhere?
Any enlightenment will be appreciated.
Vic
Re: Internal error on compile
Posted: 11 February 2008, 12:33 PM
by dkinzer
victorf wrote:What does the message mean?
An Internal Error is generated when the ZBasic compiler encounters a situation that it cannot handle. This is different from a syntax error or a semantic error which arises because an error in your code. Usually, it arises because some data element in an internal datastructure is missing or inconsistent with other data elements. In such cases, we chose to emit the Internal Error rather than to continue using bad data.
Normally, such errors should not arise. When they do, it means that either there is a coding error in the compiler or we neglected to handle a certain set of circumstances. The challenge is to locate the source of the error - often the ultimate source of the error is far removed from the point at which the problem is detected. We will attempt to reproduce the problem here using a simplified test case although this is often unsuccessful. If you can send us source code that exhibits the problem (either your full source code or a simplified test case) that will expedite locating and resolving the problem.
Re: Internal error on compile
Posted: 11 February 2008, 20:13 PM
by dkinzer
victorf wrote:While compiling the program WindReader.bas, I received the following error message:
I don't know yet why the problem is occurring but it appears that you can work around it by temporarily replacing the code on lines 357 through 361 of WindReader.bas with the following:
Code: Select all
Dim azimuth as Single
azimuth = sensordata.azimuth
xproj = cos(DegToRad(90.0 - azimuth)) _
* (height / tan(DegToRad(sensordata.elevation))) 'meters
yproj = sin(DegToRad(90.0 - azimuth)) _
* (height / tan(DegToRad(sensordata.elevation))) 'meters
The change simply introduces a temporary variable to hold the azimuth value.
Posted: 12 February 2008, 2:09 AM
by victorf
Don,
Thanks for the work-around! I'll be interested in hearing what you find after the investigation.
Vic
Posted: 12 February 2008, 15:13 PM
by dkinzer
victorf wrote:I'll be interested in hearing what you find after the investigation.
The short answer is that the problem was caused by a coding error in one of the methods of a C++ class that represents a structure member reference.
The longer answer is that code is generated for the DegToRad() function (and a few similar functions) in a special way where a new expression is constructed using a conversion factor together with the parameter provided. The C++ method for duplicating an expression element for the class that represents the structure member reference wasn't implemented correctly. This led to an inconsistency in the expression which was discovered later in the code generating process resulting in the Internal Error that you saw.
We've resolved the error and augmented the test suite to cover this and related situations.
Posted: 12 February 2008, 17:55 PM
by victorf
Don,
I replaced this in both expressions as well using the same method as you suggested for sensordata.azimuth for the sake of symmetry. Everything works fine now.
Thanks again
Vic