Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error building, loses precision #6

Open
Sembiance opened this issue May 5, 2017 · 3 comments · May be fixed by #19
Open

Error building, loses precision #6

Sembiance opened this issue May 5, 2017 · 3 comments · May be fixed by #19

Comments

@Sembiance
Copy link

Sembiance commented May 5, 2017

sembiance@riverbend ~/decrunch $ python setup.py install --user
running install
running bdist_egg
running egg_info
creating decrunch.egg-info
writing decrunch.egg-info/PKG-INFO
writing top-level names to decrunch.egg-info/top_level.txt
writing dependency_links to decrunch.egg-info/dependency_links.txt
writing manifest file 'decrunch.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'decrunch.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
building 'decrunch' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-pc-linux-gnu-g++ -pthread -fPIC -Icrunch -I/usr/include/python2.7 -c crn_decomp.cpp -o build/temp.linux-x86_64-2.7/crn_decomp.o
In file included from crn_decomp.cpp:10:0:
crunch/crn_decomp.h: In function ‘void* crnd::crnd_malloc(size_t, size_t*)’:
crunch/crn_decomp.h:2536:28: error: cast from ‘crnd::uint8* {aka unsigned char*}’ to ‘crnd::uint32 {aka unsigned int}’ loses precision [-fpermissive]
       CRND_ASSERT(((uint32)p_new & (CRND_MIN_ALLOC_ALIGNMENT - 1)) == 0);
                            ^
crunch/crn_decomp.h:435:39: note: in definition of macro ‘CRND_ASSERT’
 #define CRND_ASSERT(_exp) (void)( (!!(_exp)) || (crnd::crnd_assert(#_exp, __FILE__, __LINE__), 0) )
                                       ^
crunch/crn_decomp.h: In function ‘void* crnd::crnd_realloc(void*, size_t, size_t*, bool)’:
crunch/crn_decomp.h:2561:28: error: cast from ‘void*’ to ‘crnd::uint32 {aka unsigned int}’ loses precision [-fpermissive]
       CRND_ASSERT(((uint32)p_new & (CRND_MIN_ALLOC_ALIGNMENT - 1)) == 0);
                            ^
crunch/crn_decomp.h:435:39: note: in definition of macro ‘CRND_ASSERT’
 #define CRND_ASSERT(_exp) (void)( (!!(_exp)) || (crnd::crnd_assert(#_exp, __FILE__, __LINE__), 0) )
                                       ^
error: command 'x86_64-pc-linux-gnu-g++' failed with exit status 1
>sembiance@riverbend ~/decrunch $ x86_64-pc-linux-gnu-g++ --version
x86_64-pc-linux-gnu-g++ (Gentoo 5.4.0-r3 p1.3, pie-0.6.5) 5.4.0
sembiance@riverbend ~/decrunch $ python --version
Python 2.7.13
sembiance@riverbend ~/decrunch $ uname -a
Linux riverbend 4.10.9 1 SMP PREEMPT Tue Apr 11 10:30:30 EDT 2017 x86_64 Intel(R) Core(TM) i7-4960X CPU @ 3.60GHz GenuineIntel GNU/Linux

It builds if I change the (uint32) cast to (long) (a temporary, unadvised cheat I learned from http://stackoverflow.com/questions/1640423/error-cast-from-void-to-int-loses-precision#1640448)

Note: Using Python 3.4 doesn't fix this error.

@yiyuezhuo
Copy link

Thanks to the issue since I try to use UnityPack and build the module. In my Windows 64 plateform, the (uint32) should cast to (long long) (It's mentioned in same stackoverflow link) to get the build done.

@jleclanche
Copy link
Member

Is this still an issue in 0.4.0?

@Sembiance
Copy link
Author

Sembiance commented Jul 8, 2019

Still happening with the very latest github master version with python 3.6. And yes, changing the casts on line 2347 and 2369 from (uint32) to (long long) fixes it.

sembiance@lostcrag ~/tmp/decrunch $ sudo python setup.py install
running install
running bdist_egg
running egg_info
writing decrunch.egg-info/PKG-INFO
writing dependency_links to decrunch.egg-info/dependency_links.txt
writing top-level names to decrunch.egg-info/top_level.txt
reading manifest template 'MANIFEST.in'
writing manifest file 'decrunch.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
building 'decrunch' extension
x86_64-pc-linux-gnu-g++ -pthread -fPIC -Icrunch -I/usr/include/python3.6m -c decrunch.cpp -o build/temp.linux-x86_64-3.6/decrunch.o -std=c++11
x86_64-pc-linux-gnu-g++ -pthread -fPIC -Icrunch -I/usr/include/python3.6m -c crn_decomp.cpp -o build/temp.linux-x86_64-3.6/crn_decomp.o -std=c++11
In file included from crn_decomp.cpp:18:
crunch/crn_decomp.h: In function ‘void* crnd::crnd_malloc(size_t, size_t*)’:
crunch/crn_decomp.h:2347:23: error: cast from ‘crnd::uint8*’ {aka ‘unsigned char*’} to ‘crnd::uint32’ {aka ‘unsigned int’} loses precision [-fpermissive]
 2347 |  CRND_ASSERT(((uint32)p_new & (CRND_MIN_ALLOC_ALIGNMENT - 1)) == 0);
      |                       ^~~~~
crunch/crn_decomp.h:468:13: note: in definition of macro ‘CRND_ASSERT’
  468 |  (void)((!!(_exp)) || (crnd::crnd_assert(#_exp, __FILE__, __LINE__), 0))
      |             ^~~~
crunch/crn_decomp.h: In function ‘void* crnd::crnd_realloc(void*, size_t, size_t*, bool)’:
crunch/crn_decomp.h:2369:23: error: cast from ‘void*’ to ‘crnd::uint32’ {aka ‘unsigned int’} loses precision [-fpermissive]
 2369 |  CRND_ASSERT(((uint32)p_new & (CRND_MIN_ALLOC_ALIGNMENT - 1)) == 0);
      |                       ^~~~~
crunch/crn_decomp.h:468:13: note: in definition of macro ‘CRND_ASSERT’
  468 |  (void)((!!(_exp)) || (crnd::crnd_assert(#_exp, __FILE__, __LINE__), 0))
      |             ^~~~
error: command 'x86_64-pc-linux-gnu-g++' failed with exit status 1
sembiance@lostcrag ~/tmp/decrunch $ x86_64-pc-linux-gnu-g++ --version
x86_64-pc-linux-gnu-g++ (Gentoo 9.1.0-r1 p1.1) 9.1.0
sembiance@lostcrag ~/tmp/decrunch $ python --version
Python 3.6.8

@MosakujiHokuto MosakujiHokuto linked a pull request Sep 21, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants