Impala Public Jenkins has submitted this change and it was merged. Change subject: IMPALA-5031: Remove undefined behavior "reference binding to null" ......................................................................
IMPALA-5031: Remove undefined behavior "reference binding to null" When p has type T* and p is nullptr, then T x = p[0] has undefined behavior (obviously). Less obviously, T& x = p[0] also has undefined behavior -- references cannot be null. That undefined behavior can be caused by expressions like &v[0] when v is a vector of size 0. The issue is that the expression is parsed as &(v[0]), aka &(v.operator[](0)). The return type of the operator[] method is T&, and when v is empty the return value is a null reference. This was recognized by the C++ standards committe and fixed in Committee Draft 2008. See LWG Defect Report 464: http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#464 This patch was created by running the following command, then fixing the resulting compile errors: find be/src -type f -execdir \ sed -i 's/&\([A-Za-z0-9_]\+\)\[0\]/\1.data()/g' \{\} \; Change-Id: Ifef5c3de686318bff4eac7dfad6e1639ddadb8f2 Reviewed-on: http://gerrit.cloudera.org:8080/7008 Reviewed-by: Jim Apple <[email protected]> Tested-by: Impala Public Jenkins --- M be/src/exec/delimited-text-parser-test.cc M be/src/exec/hash-table.cc M be/src/exec/hdfs-parquet-scanner-ir.cc M be/src/exec/hdfs-parquet-scanner.cc M be/src/exec/hdfs-rcfile-scanner.cc M be/src/exec/hdfs-scan-node-base.h M be/src/exec/hdfs-scanner.h M be/src/exec/hdfs-sequence-table-writer.cc M be/src/exec/old-hash-table.cc M be/src/exec/parquet-column-stats.h M be/src/exec/parquet-column-stats.inline.h M be/src/experiments/tuple-splitter-test.cc M be/src/exprs/expr-test.cc M be/src/exprs/expr-value.h M be/src/exprs/string-functions-ir.cc M be/src/rpc/authentication.cc M be/src/rpc/thrift-util-test.cc M be/src/runtime/bufferpool/buffer-pool-test.cc M be/src/runtime/disk-io-mgr-test.cc M be/src/runtime/parallel-executor-test.cc M be/src/runtime/row-batch-serialize-test.cc M be/src/runtime/tmp-file-mgr-test.cc M be/src/udf/udf-test-harness.h M be/src/util/bitmap.h M be/src/util/coding-util-test.cc M be/src/util/coding-util.cc M be/src/util/dict-encoding.h M be/src/util/runtime-profile.cc M be/src/util/streaming-sampler.h M be/src/util/uid-util.h M be/src/util/webserver.cc 31 files changed, 70 insertions(+), 67 deletions(-) Approvals: Impala Public Jenkins: Verified Jim Apple: Looks good to me, approved -- To view, visit http://gerrit.cloudera.org:8080/7008 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ifef5c3de686318bff4eac7dfad6e1639ddadb8f2 Gerrit-PatchSet: 9 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Jim Apple <[email protected]> Gerrit-Reviewer: Dan Hecht <[email protected]> Gerrit-Reviewer: Impala Public Jenkins Gerrit-Reviewer: Jim Apple <[email protected]> Gerrit-Reviewer: Lars Volker <[email protected]> Gerrit-Reviewer: Tim Armstrong <[email protected]>
