dongjoon-hyun commented on a change in pull request #951: URL: https://github.com/apache/orc/pull/951#discussion_r740453632
########## File path: c++/src/Adaptor.hh.in ########## @@ -173,6 +174,40 @@ namespace orc { std::string to_string(int64_t val); } +#ifdef HAS_BUILTIN_OVERFLOW_CHECK + #define multiplyExact !__builtin_mul_overflow + #define addExact !__builtin_add_overflow +#else +namespace orc { + /** + * Compute value * repetitions, return false if overflow, return true otherwise + * and save the result at the address pointed to by result + * imitates the jdk Math.multiplyExact implementation + * but this method makes the assumption that repetitions > 1 + */ + static bool multiplyExact(int64_t value, int64_t repetitions, int64_t* result) { Review comment: Unfortunately, it turns out that old GCC cannot understand this correctly. ``` Started apache/main on centos7 at Mon Nov 1 10:20:20 AM PDT 2021 Cloning into 'orc'... -- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 ... [ 39%] Building CXX object c++/src/CMakeFiles/orc.dir/io/InputStream.cc.o In file included from /root/orc/c++/src/io/InputStream.hh:22:0, from /root/orc/c++/src/io/InputStream.cc:20: /root/orc/build/c++/src/Adaptor.hh:188:15: error: 'bool orc::multiplyExact(int64_t, int64_t, int64_t*)' defined but not used [-Werror=unused-function] static bool multiplyExact(int64_t value, int64_t repetitions, int64_t* result) { ^ /root/orc/build/c++/src/Adaptor.hh:200:15: error: 'bool orc::addExact(int64_t, int64_t, int64_t*)' defined but not used [-Werror=unused-function] static bool addExact(int64_t sum, int64_t increment, int64_t* result) { ^ cc1plus: all warnings being treated as errors make[2]: *** [c++/src/CMakeFiles/orc.dir/io/InputStream.cc.o] Error 1 make[1]: *** [c++/src/CMakeFiles/orc.dir/all] Error 2 make: *** [all] Error 2 FAILED centos7 ``` ########## File path: c++/src/Adaptor.hh.in ########## @@ -173,6 +174,40 @@ namespace orc { std::string to_string(int64_t val); } +#ifdef HAS_BUILTIN_OVERFLOW_CHECK + #define multiplyExact !__builtin_mul_overflow + #define addExact !__builtin_add_overflow +#else +namespace orc { + /** + * Compute value * repetitions, return false if overflow, return true otherwise + * and save the result at the address pointed to by result + * imitates the jdk Math.multiplyExact implementation + * but this method makes the assumption that repetitions > 1 + */ + static bool multiplyExact(int64_t value, int64_t repetitions, int64_t* result) { Review comment: Also, cc @williamhyun since it seems that you are looking at this area too. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@orc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org