cast from ‘stackval*’ to ‘unsigned int’ loses precision (Program Bug and Problems)

by Frédéric Bron, Wednesday, October 31, 2012, 00:35 (1724 days ago)

I am building on fedora 17 with g++ 4.7.2.
I had to apply the following changes to make the program compile. Why casting to unsigned int and dividing by sizeof(stackval)? Any particular reason not to use simple pointer arithmetics?


--- ../toto/Stack.cpp 2012-10-31 01:27:38.046538005 +0100
+++ ./Stack.cpp 2012-10-31 01:27:47.676643384 +0100
@@ -53,7 +53,7 @@
int Stack::height()
{
// return the height of the stack in elements
- return ((unsigned int) top - (unsigned int) bottom)/sizeof(stackval);
+ return top-bottom;
}

void

cast from ‘stackval*’ to ‘unsigned int’ loses precision

by Jim ⌂ @, Russell, KY, Wednesday, October 31, 2012, 18:14 (1724 days ago) @ Frédéric Bron

Thanks for catching that. You are compiling 0.9.9.1?

A fix was posted to SVN for that several weeks ago, but we have not released a new TAR or EXE since then.

cast from ‘stackval*’ to ‘unsigned int’ loses precision

by Frédéric Bron, Wednesday, October 31, 2012, 22:29 (1723 days ago) @ Jim

Yes, I am compiling 0.9.9.1. Good that it is already in svn.
Thanks,
Frédéric

RSS Feed of thread
powered by my little forum