Compile Error vs Execute Error

User ForumCompile Error vs Execute Error
jagatbirucemerlang asked 3 years ago

What is the difference between a "compile error" and an "execute error" in GAUSS?

1 Answers
aptech Staff answered 3 years ago

When you run a GAUSS program there are two major steps that occur.

First GAUSS takes the text inside your program file and turns it into a program that the computer can run. This is called compiling a program.

The second step is to run the program that was just compiled. This is when GAUSS performs the calculations and it is called run-time or execution-time.
Compile-time errors
A compile time error is an error that occurs when GAUSS was trying to compile the program. These usually occur because the program is not a legal GAUSS program. For example, GAUSS does not have a function named thisIsNotAValidFunction. So if we try and run this program:


GAUSS will give us the following compile-time error: Undefined Symbols. This is because GAUSS does not know what thisIsNotAValidFunction is, so it cannot compile it into an executable program.

Compile-time errors cannot be run through the debugger, because the debugger allows you to step through the execution of a program. As we have seen above, a GAUSS program must first be successfully compiled before it can be executed (or run).
Run-time or Execute-time errors
If a program is successfully compiled and begins to run before it hits an error condition, this will be a run-time or execution-time error. For example, the code:

x = { 1.1, 2.1, 3.1, 4.1 };
z = x[5];

will produce the run-time error: G0058 : Index out of range. In this case, GAUSS was able to compile the program, but when it tried to execute the second statement z = x[5];, it failed. This failure occurred because, the program was trying to assign the fifth element of the variable x to the new variable z, when x has only four elements.

Run-time errors can be detected using the GAUSS debugger, which is an excellent tool for helping you to locate the source of problems in your code.