[
https://issues.apache.org/jira/browse/IMPALA-5031?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16577728#comment-16577728
]
Jim Apple commented on IMPALA-5031:
-----------------------------------
Note for future fixing of signed overflow: Using {{memcpy}} is
standard-compliant but does not actually induce any extra code generated by
gcc. Check the assembly generated by:
{noformat}
#include <cstring>
#include <functional>
using namespace std;
template<typename T>
int go(int x, int y) {
return T()(x, y);
}
template<typename T>
int stop(int x, int y) {
unsigned p, q, r;
memcpy(&p, &x, 4);
memcpy(&q, &y, 4);
r = T()(p, q);
int z;
memcpy(&z, &r, 4);
return z;
}
bool plus_eq(int x, int y) {
return go<plus<>>(x, y) == stop<plus<>>(x, y);
}
bool minus_eq(int x, int y) {
return go<minus<>>(x, y) == stop<minus<>>(x, y);
}
bool multiplies_eq(int x, int y) {
return go<multiplies<>>(x, y) == stop<multiplies<>>(x, y);
}
{noformat}
Note that this does not work with division.
> UBSAN clean and method for testing UBSAN cleanliness
> ----------------------------------------------------
>
> Key: IMPALA-5031
> URL: https://issues.apache.org/jira/browse/IMPALA-5031
> Project: IMPALA
> Issue Type: Task
> Components: Backend, Infrastructure
> Affects Versions: Impala 2.9.0
> Reporter: Jim Apple
> Assignee: Jim Apple
> Priority: Minor
>
> http://releases.llvm.org/3.8.0/tools/clang/docs/UndefinedBehaviorSanitizer.html
> builds are supported after https://gerrit.cloudera.org/#/c/6186/, but
> Impala's test suite triggers many errors under UBSAN. Those errors should be
> fixed and then there should be a way to run the test suite under UBSAN and
> fail if there were any errors detected.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]