tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Incorrect cast on Windows x64


From: Christian Jullien
Subject: [Tinycc-devel] Incorrect cast on Windows x64
Date: Mon, 13 Jan 2014 07:48:01 +0100

Compiling tcc on Windows x64 using gcc, I get:

 

../tccpe.c:1806:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

         pe->start_addr = (DWORD)tcc_get_symbol_err(s1, start_symbol);

 

On Windows, DWORD is a 32bit value, you can’t cast a 64bit pointer to a 32bit integer because you may lose bits.

I had a quick look at tccpe and I can’t decide myself from http://msdn.microsoft.com/library/windows/hardware/gg463125 if pe_info is tcc specific or Windows well know structure.

 

As far I understand, DWORD start_addr should better be defined as ADDR3264 IFF pe_info is a proprietaray tcc struct that helps PE.

 

Otherwise, if by design, start_addr must be 32 value (address resides on first 4Gb address space) you’de better change the code below

 

../tccpe.c:1806:26: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

         // start_symbol resides on the first 4Gb

         pe->start_addr = (DWORD)(size_t)tcc_get_symbol_err(s1, start_symbol);

 

Christian


reply via email to

[Prev in Thread] Current Thread [Next in Thread]