28.06.2013 Views

ISO Pascal reference manual

ISO Pascal reference manual

ISO Pascal reference manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5 Errors and debugging<br />

5.1 Compile-time messages<br />

5.1.1 Warning messages<br />

Warning messages do not indicate that the program contains an error; they<br />

bring attention to various features of the program which suggest that<br />

something might be wrong. For example, one feature of <strong>Pascal</strong> which causes<br />

a lot of confusion to beginners is exactly where and when to use the<br />

semicolon. This can lead to semicolons being scattered liberally throughout<br />

the program resulting in statements like:<br />

IF cases > maximum THEN;<br />

writeln('there were too many cases');<br />

According to the rules of <strong>Pascal</strong> there is nothing wrong here, but it is<br />

unlikely that the effect will be what the user wanted. The semicolon<br />

following the THEN makes the IF control an empty (or null) statement.<br />

The `writeln' will always be executed regardless of the values of 'cases' and<br />

`maximum'. Once again it is important to stress that there is nothing wrong<br />

with the program if the effect described above is what was wanted, but as it<br />

is very likely to be a mistake the compiler will give the warning:<br />

IF cases > maximum THEN;<br />

Warning 5 -- check that an empty statement is really wanted here<br />

Below are descriptions of all of the warning messages produced by the<br />

<strong>ISO</strong> <strong>Pascal</strong> compiler.<br />

Warning 4 -- this statement can never be reached<br />

This warning is issued when the compiler detects that the indicated<br />

statement can never be executed. This is not an error, but frequently<br />

indicates an area in the program which should be checked carefully. It<br />

should be noted that this warning is only generated when it is patently<br />

obvious at compile-time that the statement cannot be executed;<br />

<strong>Pascal</strong> Issue 1 21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!