Sign in Join

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

Mailing lists / fpc-devel / 2018-01

Internal error with division by QWord (Issue #33004)

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

J. Gareth Moreton

So while testing some proposed optimisations for how div and mod operations are compiled, I came across an internal error in the compiler.

https://bugs.freepascal.org/view.php?id=33004

I haven't yet delved into the location of Internal error 200706094, but something worth bringing up because it is a fairly fundamental flaw with a relatively simple operation.

Possibly related, but the compiler automatically treats numbers larger than or equal to $8000000000000000 as signed (Int64) regardless of the context or what it's being assigned to (this usually involves compiler warnings, but also involves causing div to be signed instead of unsigned unless the constant is explicitly typecast, which raises the aforementioned internal error on 'div', but not 'mod').

Gareth aka. Kit

Reply by email

Florian Klämpfl
to J. Gareth Moreton
J. Gareth Moreton wrote 13 lines
So while testing some proposed optimisations for how div and mod operations are compiled, I came across an internal error in the compiler. https://bugs.freepascal.org/view.php?id=33004 I haven't yet delved into the location of Internal error 200706094, but something worth bringing up because it is a fairly fundamental flaw with a relatively simple operation. Possibly related, but the compiler automatically treats numbers larger than or equal to $8000000000000000 as signed (Int64) regardless of the context or what it's being assigned to (this usually involves compiler warnings, but also involves causing div to be signed instead of unsigned unless the constant is explicitly typecast, which raises the aforementioned internal error on 'div', but not 'mod').

I solved it meanwhile.

Reply by email

Sven Barth
to J. Gareth Moreton: So while testing some proposed optimisations for how div and mod operations are compiled,…

Am 11.01.2018 21:46 schrieb "J. Gareth Moreton" :

Possibly related, but the compiler automatically treats numbers larger than or equal to $8000000000000000 as
signed (Int64) regardless of the context or what it's being assigned to (this usually involves compiler
warnings, but also involves causing div to be signed instead of unsigned unless the constant is explicitly
typecast, which raises the aforementioned internal error on 'div', but not 'mod').

That such a constant is Int64 is by design as Pascal is a language that favors the signed types. If you want an unsigned constant then you need to do a cast to a suitable type.
Of course if that cast leads to an internal error then that needs to be solved.

Regards,
Sven

Reply by email

J. Gareth Moreton

On Thu 11/01/18 21:03 , Florian Klämpfl
sent:

Am 11.01.2018 um 21:46 schrieb J. Gareth

Moreton:

> So while testing some proposed

optimisations for

how div and mod operations are compiled,

I came across an

Show quoted text 5 lines
> internal error in the compiler. > > https://bugs.freepascal.org/view.php?

id=33004

> > I haven't yet delved into the location

of

Internal error 200706094, but something

worth bringing up because it

> is a fairly fundamental flaw with a

relatively

simple operation. > > Possibly related, but the compiler

automatically

treats numbers larger than or equal to

$8000000000000000 as

> signed (Int64) regardless of the

context or what

it's being assigned to (this usually

involves compiler

> warnings, but also involves causing

div to be

signed instead of unsigned unless the

constant is explicitly

> typecast, which raises the

aforementioned

Show quoted text 9 lines
internal error on 'div', but not 'mod'). > I solved it meanwhile.

That was fast!

Reply by email