facebook / redex

A bytecode optimizer for Android apps
https://fbredex.com/
MIT License
6.02k stars 653 forks source link

run autoreconf -ivf && ./configure && make error on mac os #805

Closed jusReal closed 1 year ago

jusReal commented 1 year ago

MacOs 12.3.1 intel autoconf: 2.71 automake: 1.16.5 libtool: 2.4.7 xcode-select version 2395


this is the error:

libredex/DexStructure.cpp:116:21: error: loop variable '[v, c]' of type 'const std::1::pair<DexMethodRef *const, unsigned long>' creates a copy from type 'const std::1::pair<DexMethodRef const, unsigned long>' [-Werror,-Wrange-loop-analysis] for (const auto [v, c] : b) { ^ libredex/DexStructure.cpp:314:33: note: in instantiation of function template specialization 'set_difference_size<DexMethodRef >' requested here const auto extra_mrefs_size = set_difference_size(clazz_mrefs, m_mrefs); ^ libredex/DexStructure.cpp:116:10: note: use reference type 'const std::1::pair<DexMethodRef *const, unsigned long> &' to prevent copying for (const auto [v, c] : b) { ^~~~~~~ & libredex/DexStructure.cpp:116:21: error: loop variable '[v, c]' of type 'const std::1::pair<DexFieldRef const, unsigned long>' creates a copy from type 'const std::__1::pair<DexFieldRef const, unsigned long>' [-Werror,-Wrange-loop-analysis] for (const auto [v, c] : b) { ^ libredex/DexStructure.cpp:326:33: note: in instantiation of function template specialization 'set_difference_size<DexFieldRef >' requested here const auto extra_frefs_size = set_difference_size(clazz_frefs, m_frefs); ^ libredex/DexStructure.cpp:116:10: note: use reference type 'const std::__1::pair<DexFieldRef const, unsigned long> &' to prevent copying for (const auto [v, c] : b) { ^~~~~~~ & libredex/DexStructure.cpp:116:21: error: loop variable '[v, c]' of type 'const std::1::pair<DexType *const, unsigned long>' creates a copy from type 'const std::1::pair<DexType const, unsigned long>' [-Werror,-Wrange-loop-analysis] for (const auto [v, c] : b) { ^ libredex/DexStructure.cpp:340:33: note: in instantiation of function template specialization 'set_difference_size<DexType >' requested here const auto extra_trefs_size = set_difference_size(clazz_trefs, m_trefs); ^ libredex/DexStructure.cpp:116:10: note: use reference type 'const std::__1::pair<DexType *const, unsigned long> &' to prevent copying for (const auto [v, c] : b) { ^~~~~~~ & 3 errors generated. make[2]: [libredex/DexStructure.lo] Error 1 make[1]: [all-recursive] Error 1 make: *** [all] Error 2

xixiwai0819 commented 1 year ago

I got the same error

jusReal commented 1 year ago

I solved this problem:

modify DexStructure.cpp

/**


for (const auto [v,c] : b) -> for (const auto& [v,c] : b) to prevent copying