You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/05/29 17:35:22 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #13215: ARROW-16633: [C++] Fix incorrect Decimal literal conversion in `ir_consumer.cc`

pitrou commented on code in PR #13215:
URL: https://github.com/apache/arrow/pull/13215#discussion_r884302822


##########
cpp/src/arrow/compute/exec/ir_consumer.cc:
##########
@@ -152,14 +152,14 @@ struct ConvertLiteralImpl {
     switch (t.id()) {
       case Type::DECIMAL128: {
         std::array<uint64_t, 2> little_endian;
-        std::memcpy(little_endian.data(), lit->value(), lit->value()->size());
+        std::memcpy(little_endian.data(), lit->value()->data(), lit->value()->size());

Review Comment:
   This still seems incorrect. `little_endian` is default-initialized but, as the `std::array` docs [note](https://en.cppreference.com/w/cpp/container/array), 
   > default initialization may result in indeterminate values for non-class T
   
   ... meaning that unless `lit->value->size()` is large enough, some decimal data may still be incorrect.
   
   @bkietz Am I wrong?



##########
cpp/src/arrow/compute/exec/ir_consumer.cc:
##########
@@ -152,14 +152,14 @@ struct ConvertLiteralImpl {
     switch (t.id()) {
       case Type::DECIMAL128: {
         std::array<uint64_t, 2> little_endian;
-        std::memcpy(little_endian.data(), lit->value(), lit->value()->size());
+        std::memcpy(little_endian.data(), lit->value()->data(), lit->value()->size());

Review Comment:
   This still seems incorrect. `little_endian` is default-initialized but, as the `std::array` docs [note](https://en.cppreference.com/w/cpp/container/array), 
   > default initialization may result in indeterminate values for non-class T
   
   ... meaning that unless `lit->value->size()` is large enough, some decimal data may still be undefined.
   
   @bkietz Am I wrong?



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org