View Issue Details

IDProjectCategoryView StatusLast Update
0031366FPCDocumentationpublic2017-02-11 15:47
ReporterThaddy de KoningAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
PlatformallOSallOS Versionall
Product Version3.1.1Product Build35403 
Target Version3.2.0Fixed in Version3.1.1 
Summary0031366: maxlongint is declared as a 32 value but longint is system dependent
Descriptionmaxlongint is declared as a 32 value on all systems in systemh.inc but longint is a system dependent integer type, so maxlongint can not be used on a 64 bit system.
Steps To ReproduceCheck systemh.inc for maxlongint: it is 32 bit, which is wrong on a 64 bit system unless we are not Delphi compatible with this detail.
Additional InformationThis came up when analysing the code in this link:
http://forum.lazarus.freepascal.org/index.php/topic,35751.msg236896.html#msg236896

Delphi says its longint is platform dependent:
http://docwiki.embarcadero.com/RADStudio/Seattle/en/Internal_Data_Formats
TagsNo tags attached.
Fixed in Revision1390
FPCOldBugId
FPCTarget
Attached Files

Activities

Thaddy de Koning

2017-02-08 07:57

reporter   ~0098016

Last edited: 2017-02-08 07:58

View 2 revisions

http://www.freepascal.org/docs-html/current/ref/refsu5.html#x27-27003r2

If that is correct... which it doesn't seem to be.. the bug is a Delphi incompatibility
If I am correct, it is also a bug in the docs.

Use this code on 32 bit and 64 bit:
program TestOverflowCheck;
{$OVERFLOWCHECKS ON} //same as $Q+
{$RANGECHECKS ON} //same as $R+
var
  i32 : Longint; // not true: longint is a system dependent type
 
begin
  Writeln(MaxLongint);
  i32:= MaxLongint + 2;
  Writeln(i32);
  readln;
end.

Jonas Maebe

2017-02-08 08:25

manager   ~0098017

There is no bug in the docs. Maybe one day we will add a Delphi64 modeswitch or so, but by default longint will always be 32 bits in FPC.

Thaddy de Koning

2017-02-08 08:59

reporter   ~0098018

Last edited: 2017-02-08 09:00

View 2 revisions

Can I ask in a separate report to add this to docs as a known incompatibility with Delphi?
If that is the case then this can be closed.
Your explanation both here and on the forum is clear.

Thaddy de Koning

2017-02-08 09:13

reporter   ~0098019

Last edited: 2017-02-08 09:16

View 3 revisions

Editted away.
I had some apple issue on 64 bit

Marco van de Voort

2017-02-08 11:25

manager   ~0098020

In your embarcadero reference:

"The platform-dependent integer types are transformed to fit the bit size of the current target platform. On 64-bit platforms they occupy 64 bits, on 32-bit platforms they occupy 32 bits (except the LongInt and LongWord types)"

I read that as that the longint and longword types are excluded from scaling with 32/64 size.

Thaddy de Koning

2017-02-08 12:20

reporter   ~0098021

No on MAC its is expclicitly documented as 64 bit on a 64 bit system.

Marco van de Voort

2017-02-08 12:57

manager   ~0098022

It says iOS, but that is the "newgen" compiler.
It doesn't say explicitely what it does on OS X.

Anyway, this is convoluted, moreover I don't see the use of following this.

Michael Van Canneyt

2017-02-08 14:32

administrator   ~0098026

The bug is delphi compatibility.
Currently, longint in FPC is 32-bit, everywhere.

I will document this.

Marco van de Voort

2017-02-08 15:22

manager   ~0098029

Afaik the new linux port is 64-bit and nextgen compiler. It might be wortwhile checking what that does.

Michael Van Canneyt

2017-02-11 15:47

administrator   ~0098102

Documented that in FPC, longint is 32-bit.

Issue History

Date Modified Username Field Change
2017-02-08 07:46 Thaddy de Koning New Issue
2017-02-08 07:57 Thaddy de Koning Note Added: 0098016
2017-02-08 07:58 Thaddy de Koning Note Edited: 0098016 View Revisions
2017-02-08 08:25 Jonas Maebe Note Added: 0098017
2017-02-08 08:59 Thaddy de Koning Note Added: 0098018
2017-02-08 09:00 Thaddy de Koning Note Edited: 0098018 View Revisions
2017-02-08 09:13 Thaddy de Koning Note Added: 0098019
2017-02-08 09:16 Thaddy de Koning Note Edited: 0098019 View Revisions
2017-02-08 09:16 Thaddy de Koning Note Edited: 0098019 View Revisions
2017-02-08 11:25 Marco van de Voort Note Added: 0098020
2017-02-08 12:20 Thaddy de Koning Note Added: 0098021
2017-02-08 12:57 Marco van de Voort Note Added: 0098022
2017-02-08 14:31 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-02-08 14:31 Michael Van Canneyt Status new => assigned
2017-02-08 14:32 Michael Van Canneyt Note Added: 0098026
2017-02-08 14:33 Michael Van Canneyt Category RTL => Documentation
2017-02-08 15:22 Marco van de Voort Note Added: 0098029
2017-02-11 15:47 Michael Van Canneyt Fixed in Revision => 1390
2017-02-11 15:47 Michael Van Canneyt Note Added: 0098102
2017-02-11 15:47 Michael Van Canneyt Status assigned => resolved
2017-02-11 15:47 Michael Van Canneyt Fixed in Version => 3.1.1
2017-02-11 15:47 Michael Van Canneyt Resolution open => fixed
2017-02-11 15:47 Michael Van Canneyt Target Version => 3.2.0