Re: casting on 64/32-bit environment

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

 



Mitja Ursic writes:
 > 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?
 > 
 > 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.

You're casting from a pointer to an integer.  This is the wrong thing
to do.

 > 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

Don't do this.  The answer to your problem is to not cast a pointer to
an integer.  If you can explain why you want to do such casting, we'll
be able to tell you how to avoid it.

Andrew.

[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