Playermet / codegoogle.anic

Automatically exported from code.google.com/p/anic
0 stars 0 forks source link

Casting pointer to unsigned int can cause compilation failure on some 64-bit machines #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Compiling anic on my computer results in the following errors. I have attached 
a patch to fix these errors.

src/types.cpp: In member function ‘TypeStatus::operator unsigned int() 
const’:
src/types.cpp:1048: error: cast from ‘Type*’ to ‘unsigned int’ loses 
precision
src/semmer.cpp: In function ‘void buildSt(Tree*, SymbolTable*, 
std::vector<SymbolTable*, std::allocator<SymbolTable*> >&)’:
src/semmer.cpp:244: error: cast from ‘Tree*’ to ‘unsigned int’ loses 
precision
src/semmer.cpp:256: error: cast from ‘Tree*’ to ‘unsigned int’ loses 
precision
src/semmer.cpp:277: error: cast from ‘Tree*’ to ‘unsigned int’ loses 
precision

The problem is that, on my machine, unsigned int is defined as having a 32-bit 
size, while pointers have a 64-bit size. There is a typedef called uintptr_t in 
stdint.h which is always the same size as a pointer on the target computer. My 
patch merely changes the casts from unsigned int to uintptr_t.

Original issue reported on code.google.com by thebuck...@gmail.com on 13 Jun 2010 at 5:46

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I concur, and can validate that the suggested typedef does the trick.

Original comment by cbbro...@gmail.com on 11 Aug 2010 at 6:32

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Good catch, MikeB. I just pushed the fix to the default branch.

Cheers!
Adrian (project lead)

Original comment by ultimus@gmail.com on 19 Aug 2010 at 6:08

GoogleCodeExporter commented 8 years ago
Thanks Adrian!

Original comment by thebuck...@gmail.com on 19 Aug 2010 at 2:33

GoogleCodeExporter commented 8 years ago
I tried building today and got: http://pastie.org/1294295
My system is Archlinux x86_64.

Original comment by m.fellin...@gmail.com on 13 Nov 2010 at 2:38