BUG: gpc and type modifiers.
Thu, 3 Oct 96 14:53:43 CST
I discovered a bug in the way GPC treats type modifiers:
Consider this snippet, for a 32bit architecture:
-------------------------------------------
type
uint = __unsigned__ integer; { unsigned 32-bit }
const
c1 : uint = $7FFFFFFF ; { maxint }
c2 : uint = $80000000 ;
-------------------------------------------
The declaration of c2 gives this error message:
`integer constant does not fit in integer type'
while this faulty snippet is accepted:
-------------------------------------------
type
short = __short__ integer; { signed 16-bit }
const
c3 : short = $FFFF ;
c4 : short = $00010000 ;
-------------------------------------------
Although c4 gives a warning:
`warning: overflow in implicit constant conversion'
Obviously, GPC doesn't treat the type modifiers the right way when it
evaluates whether a constant is valid or not.
The same is true for __longlong__ (64bit), which cannot be initialized
with a value > $7FFFFFFF.
Workaround
==========
With this silly trick it's still possible to assign an unsigned 32bit
value:
-------------------------------------------
type
uint = __unsigned__ integer; { unsigned 32-bit }
const
c1 : uint = $7FFFFFFF + 1;
-------------------------------------------
This gives again:
`warning: overflow in implicit constant conversion'
which can be suppressed by surrounding the declaration with {$W-} .. {$W+}
JanJaap
---
"Nothing shocks me, I'm a scientist", Indiana Jones
J.J. van der Heijden (j.j.vanderheijden@student.utwente.nl)
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es