long pointer issue with newer gcc compilers

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

 



Hello,

I'm building an older codebase on RE5 and the casting of a long pointer is
somehow not working. It works when i compile on RE4.

RE5 compiler is gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14)

RE4 compiler is gcc (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1)

Here is an example of the code.

char *hdr ;
char *p;
unsigned hl;

hdr = malloc(256 );
p=hdr;
hl = 32;
*((long *)(p)) = *((long *)(&hl));
hl = 0;
*((long *)(&hl)) = *((long *)(p));
printf("hl = %d p = %x\n",hl,p);
p+=4 ;



Now if i change the long * to int * the RE5 compiler works fine.

This isn't a compile error its a run time unexpected value error.

Any help would be appreciated.

thanks

Bill
-- 
View this message in context: http://www.nabble.com/long-pointer-issue-with-newer-gcc-compilers-tp20502954p20502954.html
Sent from the gcc - Help mailing list archive at Nabble.com.


[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