Re: recasting an error to a warning?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Winstead wrote:
Using gcc on a Itanium chip with Linux SUSE I get the error message (and similar ones): /localviews/hpc/vc/src/ace/ace_virtual.cpp:1714: error: cast from 'void*' to 'int' loses precision

I know that what is happening is a 64 bit value is being cast to a 32 bit value. The problem is I've counted 427 instances of this or a like error. The developer's say they've made this code work on other 64 bit platforms -- what is going on is that they took a 32 bit value and stored it in the larger, and this is coming back down. (no, I don't know why they did this). So it just needs a simple truncation.

Either there is a flag hidden in the makefiles that is promoting a warning to an error here, or I hope there is a flag that casts this error to a warning. Help?

I don't have this problem in any C++ code I maintain, but the way we suppress the warning in C code is by Writing Good Code; IOW, make it explicit what you are doing, like this:

int foo = (int)(long)ptr;

The cast from void* to long is usually correct (if not, replace it with something that you erliably typedef to be 'an integer whose size == sizeof(void*)'). Then you can safely downcast the larger integer to a (potentially) smaller integer (int).

--
Matthew
Microsoft: driving people fscking insane...


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux