Page 1 of 1

Wrong overflow message

Posted: Fri Aug 10, 2007 10:58 am
by Trond
This is ok:

Code: Select all

a.l = $ffffffff
But this, which should only flip the bits, is not:

Code: Select all

a.l = ~$ffffffff
Changing the value of the individual bits should not result in more bits.

Posted: Fri Aug 10, 2007 11:06 am
by Kaeru Gaman
bug confirmed for 4.02 Win, too

...does the compiler generate quads out of literals?

then ~$ffffffff will result in $ffffffff00000000 wich is too big for long.

Re: Wrong overflow message

Posted: Tue Jun 20, 2017 12:23 am
by Fig
Up...

Re: Wrong overflow message

Posted: Wed Jun 21, 2017 7:39 am
by netmaestro
Please read before submitting a bug report! wrote:(12) Once a bug as been reported, please don't 'bump' the topic by adding a new post like 'this bug is till not fixed in the new release'. We are aware about it. We read all the bugs, if it's not set as 'Fixed', then we didn't found a solution for now.
One of the very best ways to irritate the team is to bump bug reports.

Re: Wrong overflow message

Posted: Wed Jun 21, 2017 9:06 am
by Fig
netmaestro wrote:
Please read before submitting a bug report! wrote:(12) Once a bug as been reported, please don't 'bump' the topic by adding a new post like 'this bug is till not fixed in the new release'. We are aware about it. We read all the bugs, if it's not set as 'Fixed', then we didn't found a solution for now.
One of the very best ways to irritate the team is to bump bug reports.
You are really clever so you know this bug is easy to fix...
I don't want to irritate the team but this probably had slipped off the punch-list since 10 years.
There can be no other explanation. So a polite and gentle bump up is appropriate once every 10 years. (despites the rules, which was made for a purpose, probably prevents bugs to be bumped every days by impatient users)

When you use a long chain of boolean math to achieve a good optimisation, you can get completly insane with that kind of bug.
This is a basic (like addition or divide), not some kind of third party bugged library.
So, please, don't irritate the customer either, we all want Purebasic to get reliable like a professional language.
This is not a decennial attack against the team, it's for everyone's sake. So I assume the team understand and is not irritated. (anyway they can PV me themself if so, which is a smart move to correct someone's behaviour. Isn't it ?)

Re: Wrong overflow message

Posted: Fri Jun 30, 2017 1:52 am
by Olliv
I have no computer, but is this bypass ok?

Code: Select all

A.L = -1
A ! (-1)
... and technically faster than 'not' asm statement?

Re: Wrong overflow message

Posted: Fri Jun 30, 2017 2:20 pm
by Fig
actually if you do:

Code: Select all

a.l=$ffffffff
a=~a
Debug a
It also works...

Re: Wrong overflow message

Posted: Fri Jun 30, 2017 10:43 pm
by Olliv
Mh...

Ten years ago, I had a first project on PureBasic which did not work for a problem of background on 3D I could not absolutely solve.

I send different public reports on french and english forum.

No answer.

This project was free for me. The goal : help a friend which thank I reach. He was sure I reached to help him.

Unhappily he died before I could give him whatever I promised.

And I do not believe he is looking me from the sky today.

Also, I did not say anything about this bad story to Fred. And I did not use some words which allow anybody to see the deep and useless feeling I was taken.

Nothing. I had just an answer from NetMaestro which helped me to make transparent bubbles, on the desktop, to give a laugh to Kcc, for which goal?
Nothing.

For money?
No.

There is no goal or money which breaks the death of my friend to see I reach what he wanted.

Today, Fred has perfectly debugged since four years the bug I reported. It was five years toomuch, and too late for me.

I do not think I gave a talk, neither private, neither public to Fred which was otherone than a 'thank you' when I discovered the bug was fixed, even if it changed nothing for me.

It was a pleasure to learn from a person as Mister Gallant, there is an on-line manual to learn myself.
A pleasure to see some pictures created by his wife, especially a flower I just remember, because I did not find the interest to record it, but the lonely interest to remember it.

I talk about this, because it is in this subject. And there is lots of subjects !

Lots of people too which can't talk as we are able to do. And they never had forced me to pay them to have anything.

Also, if I can approach a keyboard, I will 'waste' my time to understand if such a bug is really important. I do not think.

What it is important is when people are agree together. Because, in the discord, all is wasted without break, beginning by the health. That is the point of view of an other 'customer' which can't read your recent source, but which appreciates too, and hope you will reach what you decided for you...

Re: Wrong overflow message

Posted: Sat Jul 01, 2017 9:28 am
by Lunasole
Olliv wrote:Mh...
Ten years ago, I had a first project on PureBasic which did not work for a problem of background on 3D I could not absolutely solve.
Probably this will be disappointment for you, but fail of your project is always your fail, not fail of software tools you used for it (used human tools may be a source of fail, but not sw ^^).
Just because it is obvious that any "serious" project (i.e. which requires "lot of efforts" and is quite more complicated than another helloworld) requires that much serious planning/preparations. If you didn't make them well, it is only your problem.

I also failed with one my game I tried time ago (hah, that was noticeable long-run for 6+ months, before finally drown in several different directions ^^) , but for me it was clear at the planning stage that some PB libraries cannot provide enough functionality/abilities, so I just didn't used them. Situation with bugs is the same -- it's not a big deal to do some tests on that "planning stage" to ensure, before you start using some stuff in real project.


PB. But well, about PB bugs, I'm sure the situation was very bad time ago (there are so much old reports, including some guinnessbook-bugs not fixed for 10 years). I'm glad that for recent few years it all looks a lot better (partially because modern PB uses more often those nicely made/debugged open-source libraries [unlike old, which was using mostly own code and that code probably became too complex for a small team to maintain], and partially because code skills of team evolved). As for me, nowadays most of really important/impassable things are fixed fast enough
(so in that direction PB is enough "professional" and reliable, thats for @Fig. even with temporary workarounds you need sometime like in this case, total waste of time/efforts is much more less than you waste if do equal things in any other known "true professional codemonkey approved" language with zero probability to struggle any language/runtime bugs).

Re: Wrong overflow message

Posted: Sun Jul 02, 2017 2:11 am
by Olliv
@Fig

1) On PureBasic 5.50 x64, to invert quads $FFFFFFFF and $FFFFFFFFFFFFFFFF : works perfectly fine.

2) To read an hexa long value, as written in the doc, we must specify #PB_Long, because the default format is quad. If problem occurs, a complete message in the bug doc area is certainly welcomen. Technically, if you want to treat with unsigned, you can do it in assembly, what is the best solution to optimize. You will see then a constant is unabled in the 'all bit inverting' 'not' statement : if problem, you are the customer of Intel or AMD which uses Intel stantard, so write to Intel.

3) To check what is a long in PB, we can see this doc page : Variables and types, what it allows us to forsee what is the numeric defining domain for long types. As we can see in this old fake subject, it is sure that an overflow on x86 causes an overflow message.

$FFFFFFFF = unsigned format
-1 = signed format

Re: Wrong overflow message

Posted: Tue Jul 11, 2017 11:49 am
by Fred
All numerics are treated as quad internally, that's why the affection doesn't work.

Re: Wrong overflow message

Posted: Thu Feb 01, 2018 12:54 pm
by Kurzer
@Fred: Does this mean, using an Integer variable (because it's the nativ and fastes datatype of the currently used CPU) is actually sensless?

I stumbled over this thread because I have a similar problem.
If I compare two unsigned integer values on a x86 system I get a wrong result, even if I try to unsign the variable using & $ffffffff
Please compile the following code with a x86 and a x64 Compiler and compare the results:

Code: Select all

; Compile this in x86 mode and then in x64 mode

EnableExplicit

#Max = $FFFFFFFE

Procedure.s TestI(Value.i)
	CompilerIf #PB_Processor_x64
		If Value & $ffffffffffffffff > #Max & $ffffffffffffffff
	CompilerElse	
		If Value & $ffffffff > #Max & $ffffffff
	CompilerEndIf
		ProcedureReturn Str(Value) + " is greater than " + Str(#Max)
	Else
		ProcedureReturn Str(Value) + " is lower than " + Str(#Max)
	EndIf
EndProcedure

Procedure.s TestL(Value.l)
	If Value & $ffffffff > #Max & $ffffffff
		ProcedureReturn Str(Value) + " is greater than " + Str(#Max)
	Else
		ProcedureReturn Str(Value) + " is lower than " + Str(#Max)
	EndIf
EndProcedure

Procedure.s TestQ(Value.q)
	If Value & $ffffffffffffffff > #Max & $ffffffffffffffff
		ProcedureReturn Str(Value) + " is greater than " + Str(#Max)
	Else
		ProcedureReturn Str(Value) + " is lower than " + Str(#Max)
	EndIf
EndProcedure

Debug TestI($4)
Debug TestL($4)
Debug TestQ($4)
The x86 Result wrote: [12:39:46] [Debug] 4 is greater than 4294967294
[12:39:46] [Debug] 4 is greater than 4294967294
[12:39:46] [Debug] 4 is lower than 4294967294
The x64 Result wrote: [12:39:46] [Debug] 4 is lower than 4294967294
[12:39:46] [Debug] 4 is lower than 4294967294
[12:39:46] [Debug] 4 is lower than 4294967294
The Result of TestI() and TestL() on a x86 system will be wrong. On a x64 system all results are okay.

Is using a quad variable really the only solution to compare two unsigned long values on a x86 system?
And how I can compare two unsigned quad values?

Code: Select all

#QMax = $FFFFFFFFFFFFFFFE
If Value & $ffffffffffffffff > #QMax & $ffffffffffffffff
Does not work.