as title, I get a compile error when I use the mod operator in constant expressions.
eg, with this program ...
program pmod (Output); const c = 9 mod 5; { <<<< error } begin WriteLn ('9 mod 5 is ', c); end. { pmod }
pmod.pas:3: error: constant has non-constant value
I can rewrite the constant as
c = 9 - 5*(9 div 5); { this is equivalent to 9 mod 5 }
without problems.
This seems strange to me - am I missing something? What makes it a non-constant?
Many Thanks
Le 17/10/2014 14:57, trevor a écrit :
as title, I get a compile error when I use the mod operator in constant expressions.
I had found previously the same bug with gcc backend 4.3.5 See http://www.g-n-u.de/pipermail/gpc/2013-April/015222.html
I thus reverted to previous gcc backends, which do not display this bug.
Maurice
On 17/10/14 22:00, Maurice Lombardi wrote:
Le 17/10/2014 14:57, trevor a écrit :
as title, I get a compile error when I use the mod operator in constant expressions.
I had found previously the same bug with gcc backend 4.3.5 See http://www.g-n-u.de/pipermail/gpc/2013-April/015222.html
I thus reverted to previous gcc backends, which do not display this bug.
Maurice
Thanks for this info.
Following your link, I tried putting parenthesis around the mod term and, yes, it works for me as well. I should have said I am using gcc 3.4.6 backend, on 64 bit linux - but my version of gpc was built with gcc 4.x and uses the 4.x libraries. I'll try a rebuild with gcc 3 - maybe that will help.
-- Trevor//