Nonportable code in C++ support

Andreas Pakulat apaku at
Wed Feb 13 09:11:48 UTC 2008

On 13.02.08 00:36:48, David Nolden wrote:
> On Wednesday 13 February 2008 00:21:26 Andreas Pakulat wrote:
> > Hi,
> >
> > apparently there's some non-portable code in C++ support and with
> > non-portable I mean building breaks on anything but 32 bit platforms.
> >
> > The problem is hashFromFunction in typerepository.cpp, line 665 and
> > following. There a pointer is casted to int, which obviously won't work
> > on 64 bit where this is a long.
> >
> > The error that was reported is that the cast to int looses precision,
> > however I don't see a way to preserve the precision as we need to get an
> > int out of the function. Ideas?
> >
> > Oh and apparently s/int/long in 265, 266 and 267 fixes the build issue.
> >
> > Andreas
> Hi! The code compiles just fine on my 64 bit machine(there was an issue some 
> time, but that was fixed). Where does the build fail?

Somebody popped up in #kdevelop and had an error saying that the cast
looses precision. He was on 64 bit and changing from int to long fixed
the build for him.

The error was for line 265 and 266.

I'm not sure wether precision-loosing is actually an error or just a
warning and he somehow had -Werror set (or maybe -pedantic, aaah gcc has
soooo many options)...

> Since the int does not need to 100% represent the pointer, but rather is just 
> used as an approximate hash-value, the conversion should not be problematic.

Ok, then I think casting to long is better, it doesn't break on 32 Bit
and obviously fixes some 64 Bit builds.


You will be honored for contributing your time and skill to a worthy cause.

More information about the KDevelop-devel mailing list