[fpc-devel] compiler bug?

Jose Manuel qkysoft at arrakis.es
Sun Jan 2 17:01:08 CET 2005


> I think it's slightly subtler. I guess that this code:
>
>   if not b then
>      WriteLn('False')
>   else if b then
>      WriteLn('True')
>   else
>      WriteLn('Other');
>
> ...could throw a different result.
>
> IIRC, any non-zero value is evaluated as "True" for a Boolean
> variable. The

No, and no. There your assuming some implementation of the type Boolean.
I Peter stated, bitwise logic and Boolean logic are neatly separated in
Pacal. You say you're not counting on how it's implemented and still insists
in expressions as "True <> 0". No way.

> problem with the case statement is that Jesús is asking the
> compiler which
> specific value it chooses for assignements... and getting
> surprised because
> it's not what he expected. I guess the compiler uses 1 instead of
                             ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
> 255. But

Dodi told you, Peter told you and I tell you now. Don't guess anything about
how a compiler internally implementens a type. Peter could have said so
louder but not clearer: if you cast a type into another type that can result
in an overflow, it's programmer's fault, 'cause at least in Pascal
(exceptions apart) those cast have to be done explicitly. And you can't
trust wheter True is 255, 1, -1 or use simply another bit pattern or
whathever, which is perfectly legal, Don't ya say you agree with everyone
when you are clearly on the contrary.


I think this is goin' far behind this list is intended to. All I can say is
that there should be some kind of compatibility for those who, as me (:-(
guilty), sometimes recurre to Fix'n Dirty, I mean: FPC (at least in FPCOBJ
or DELPHI compatibilty mode), Kilyx and Delphy should behave the same, but
as long as Kylix and Delphi don't keep the same (sane?) behaviour, it's up
to you, FPC developers to choose what you find more (efficient?, accurate to
reality, compatible? I dunno, but surely you do)....
Anyway, I think it's pointless to go on with this

> it's surely documented anyway.

The internal implementation of a Boolean type, I guess it ain't? Surely for
every compiler it is, but there's no standard way and I'm quite sure there's
no standard how it should behave when typecasting.
>
> --
> saludos,
>
>     Nico Aragón

Bye, Nico and everyone.

--
  JMR

BTW: I don't wish everyone "Happy Christmas" 'cause there are a lot of
religions, and to too many of them, Christmas has no sense. Anyhow my best
wishes to everyone

For Dodi's Sake (What he asked Nico about his 'rudimentary spanish'), and to
anyone who might be interested:

a) ¡Hola, Torpedo!
That's slang. You could translate it into 'Hi, Dork!'

b) Feliz Año:
In effect, it's the same as in English: It means merely: 'Happy new year!'









More information about the fpc-devel mailing list