Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-04

32 bit fpc gives no warning for cast that fails on 64 bit?

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

Maybe it's my setting, but I get other warnings, hints even..

var
   p: Pointer;
   e: TEnumType;
begin
   e:= TEnumType(p);

didn't give me any warning (2.4.0, 2.5.1), but it fails (so I am told) on 64bit, [ Illegal type conversion: "^untyped" to "<enumeration type>"]

If untyped^ to enum is forbiden, then why does it even *work* on 32 bit? (not to speak, of not giving a warning?)

Martin

Reply by email

Jonas Maebe
to Martin
Martin wrote 11 lines
Maybe it's my setting, but I get other warnings, hints even.. var p: Pointer; e: TEnumType; begin e:= TEnumType(p); didn't give me any warning (2.4.0, 2.5.1), but it fails (so I am told) on 64bit, [ Illegal type conversion: "^untyped" to "<enumeration type>"] If untyped^ to enum is forbiden, then why does it even *work* on 32 bit? (not to speak, of not giving a warning?)

It works in 32 bit because the default size of enumeration types is 4 bytes (also on 64 bit platforms, to avoid problems with reading binary files containing enumeration types), and explicitly type casting one type to another type of the same size is always allowed.

Jonas

Reply by email

Martin
to Jonas Maebe
Jonas Maebe wrote 17 lines
On 17 Apr 2010, at 21:47, Martin wrote: > Maybe it's my setting, but I get other warnings, hints even.. > > var > p: Pointer; > e: TEnumType; > begin > e:= TEnumType(p); > > didn't give me any warning (2.4.0, 2.5.1), but it fails (so I am told) on 64bit, [ Illegal type conversion: "^untyped" to "<enumeration type>"] > > If untyped^ to enum is forbiden, then why does it even *work* on 32 bit? (not to speak, of not giving a warning?) > It works in 32 bit because the default size of enumeration types is 4 bytes (also on 64 bit platforms, to avoid problems with reading binary files containing enumeration types), and explicitly type casting one type to another type of the same size is always allowed.

ah yes, I see, so a warning would upset many people using other 64bit unsave code....
My initial confusion was when I saw the error message => I thought the problem was because it was untyped (and it was untyped in 32 bit too

Maybe at some point a switch -w#### some way to enable warnings for code that isn't 64/32 compatible?

Martin

Reply by email