This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: casting on 64/32-bit environment
- From: "Mitja Ursic" <mitja dot ursic at email dot si>
- To: "Andrew Haley" <aph-gcc at littlepinkcloud dot COM>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 22 Oct 2007 08:58:34 +0200
- Subject: Re: casting on 64/32-bit environment
On Fri, 12 Oct 2007 at 15:46:14, Andrew Haley wrote:
> The problem here is that we don't know what you don't understand.
>
> If you're casting a pointer to an (32-bit) int, then if you are on a
> 64-bit system, there will be overflow and some information will be
> lost. If you're on a 32-bit system then there won't be a problem.
> This seems obvious: what's the problem?
>
> Andrew.
Sorry for very late replay. My OS is 64 bit (Linux Red Hat 4 WS, Update 4, 64-
bit). I want to compile a program in 64-bit environment but due to casting I
don't trust to the compiled program. So I want to figure out which steps are
necessary to take and than to compiled program on 64-bit without casting
warnings. So if you have any advice what to do I would be happy. Perhapse a
part of a code would help to figure out what is the cause of my problems.
So, this is my casting warning:
func.cc: In function `void func()': func.cc:105: warning: cast to pointer from
integer of different size
PtrF.h: In constructor `PtrF<Element>::PtrF(Element*) [with Element = el]':
func.cc:105: instantiated from here PtrF.h:39: warning: cast from pointer to
integer of different size
Down I give a part of a code:
//FUNC.CC
void func ()
{
â
int iel=0;
â
PtrF <EL> el01 = (EL*) iel; //line 105
â
}
//PTRF.H
template <class Element>
class PtrF : public PtrC<Element>
{
public:
â
//constructor at line 39
PtrF(Element* ele):Ptr<Element>(ele),_vide((int)ele) {}
â
private :
int _vide;
};
//CLASS PTR
template <class Element>
class Ptr : public Obj
{
public:
â
//constructor
Ptr(Element *pointerEl = 0):_impP(new ImpP<Element>(pointerEl)){}
â
protected:
ImpP<Element> *_impP;
};
//CLASS IMPP
template <class Element> class ImpP
{
â
private:
Element* _ptr;
â
//constructor
ImpP(Element * element = 0):_ptr(element) {}
} ;
//EL CLASS
class EL : public Obj
{
â
public :
// constructor
EL(int vi,int vj, int vk):i(vi),j(vj),k(vk) {}
â
int i,j,k;
â
};
Mitja
____________________
http://www.email.si/