Pascal Viandier wrote:
The following sample code does not compile properly with GPC (20050331).
Program Real; Var R1, R2 : Real; Begin  R1 := 4.21; R2 := R1 * -1.0; WriteLn(R2); End.
GPC output: real.pas:6: error: syntax error before `-'
The problem occurs with negative integer constants and any operator (+-*/) as well.
Strange enough, if I modify the code for: R1 := 4.21; R2 := -1.0; R2 := R1 * R2;
Or even for: R2 := -1.0 * R1;
The code compiles and the output is as expected. It looks like one can assign a negative constant to a variable but cannot use it as an operand if it is on the right side. This is not a problem for multiplying but for the other operators... Could this be a bug?
No, it's a simple parentheses. The correct Pascal syntax is: R1 * (-1.0) Borland Pascal has a different (non-standard) precedence for unary minus, so this works there. GPC does this with `{$borland-pascal}' (not by default, as it may cause non-standard results in other cases). Frank -- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8