You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "huberylee (via GitHub)" <gi...@apache.org> on 2023/12/29 09:39:44 UTC

[PR] GH-39387: [C++] Fix compile warning [arrow]

huberylee opened a new pull request, #39389:
URL: https://github.com/apache/arrow/pull/39389

   <!--
   Thanks for opening a pull request!
   If this is your first pull request you can find detailed information on how 
   to contribute here:
     * [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
     * [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
   
   
   If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
   
   Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
   
   Then could you also rename the pull request title in the following format?
   
       GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   or
   
       MINOR: [${COMPONENT}] ${SUMMARY}
   
   In the case of PARQUET issues on JIRA the title also supports:
   
       PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
   
   -->
   
   ### Rationale for this change
   
   Fix compile warning:
   ```bash
   In file included from /workspace/arrow/cpp/src/arrow/array/array_base.h:26:
   /workspace/arrow/cpp/src/arrow/array/data.h:452:19: warning: unused variable 'buffer_length' [-Wunused-variable]
       const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
                     ^
   /workspace/arrow/cpp/src/arrow/array/data.h:467:19: warning: unused variable 'buffer_length' [-Wunused-variable]
       const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
                     ^
   2 warnings generated.
   ```
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   ### What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ### Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   ### Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
   -->
   <!-- **This PR includes breaking changes to public APIs.** -->
   
   <!--
   Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
   -->
   <!-- **This PR contains a "Critical Fix".** -->


-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv merged PR #39389:
URL: https://github.com/apache/arrow/pull/39389


-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #39389:
URL: https://github.com/apache/arrow/pull/39389#discussion_r1438135550


##########
cpp/src/arrow/array/data.h:
##########
@@ -449,7 +449,8 @@ struct ARROW_EXPORT ArraySpan {
   /// \return A span<const T> of the requested length
   template <typename T>
   util::span<const T> GetSpan(int i, int64_t length) const {
-    const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
+    [[maybe_unused]] const int64_t buffer_length =

Review Comment:
   can we just remove this line?
   
   cc @jsjtxietian 



-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #39389:
URL: https://github.com/apache/arrow/pull/39389#issuecomment-1873641934

   Happy new year and thanks @felipecrv @huberylee !


-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #39389:
URL: https://github.com/apache/arrow/pull/39389#discussion_r1438137223


##########
cpp/src/arrow/array/data.h:
##########
@@ -449,7 +449,8 @@ struct ARROW_EXPORT ArraySpan {
   /// \return A span<const T> of the requested length
   template <typename T>
   util::span<const T> GetSpan(int i, int64_t length) const {
-    const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
+    [[maybe_unused]] const int64_t buffer_length =

Review Comment:
   Oh we cannot, `assert` will check it when debug mode



-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #39389:
URL: https://github.com/apache/arrow/pull/39389#discussion_r1438239115


##########
cpp/src/arrow/array/data.h:
##########
@@ -449,7 +449,8 @@ struct ARROW_EXPORT ArraySpan {
   /// \return A span<const T> of the requested length
   template <typename T>
   util::span<const T> GetSpan(int i, int64_t length) const {
-    const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
+    [[maybe_unused]] const int64_t buffer_length =

Review Comment:
   Can we replace `buffer_length`  in `assert()` with `/* buffer length */(buffers[i].size / static_cast<int64_t>(sizeof(T)))`?
   
   BTW, we have `ARROW_UNUSED()` macro.



-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on PR #39389:
URL: https://github.com/apache/arrow/pull/39389#issuecomment-1872452798

   Thanks @huberylee 
   
   I will wait some days and waiting for others to take a look


-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #39389:
URL: https://github.com/apache/arrow/pull/39389#issuecomment-1871881269

   :warning: GitHub issue #39387 **has been automatically assigned in GitHub** to PR creator.


-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on code in PR #39389:
URL: https://github.com/apache/arrow/pull/39389#discussion_r1439112316


##########
cpp/src/arrow/array/data.h:
##########
@@ -449,7 +449,8 @@ struct ARROW_EXPORT ArraySpan {
   /// \return A span<const T> of the requested length
   template <typename T>
   util::span<const T> GetSpan(int i, int64_t length) const {
-    const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
+    [[maybe_unused]] const int64_t buffer_length =

Review Comment:
   > can we just remove this line?
   > 
   > cc @jsjtxietian
   
   It's quite an important assert, because the caller is supposed to pass the correct length when calling these functions.



-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #39389:
URL: https://github.com/apache/arrow/pull/39389#issuecomment-1873616448

   After merging your PR, Conbench analyzed the 6 benchmarking runs that have been run so far on merge-commit 3087c941699ea8485de619b8a36d98322fe20aa0.
   
   There was 1 benchmark result with an error:
   
   - Commit Run on `ursa-i9-9960x` at [2024-01-02 02:41:53Z](https://conbench.ursa.dev/compare/runs/fee03bffd2444dd1900f39449fe8d869...c4ad926ac49243f8a7f66b58c4e89041/)
     - [`dataframe-to-table` (R) with dataset=chi_traffic_2020_Q1, language=R](https://conbench.ursa.dev/benchmark-results/065937f04e4c7b7b8000a6895a0e7379)
   
   There were no benchmark performance regressions. 🎉
   
   The [full Conbench report](https://github.com/apache/arrow/runs/20081925322) has more details. It also includes information about 2 possible false positives for unstable benchmarks that are known to sometimes produce them.


-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "felipecrv (via GitHub)" <gi...@apache.org>.
felipecrv commented on PR #39389:
URL: https://github.com/apache/arrow/pull/39389#issuecomment-1873553134

   Merging now and saving many engineers coming back from vacation of the annoyance of this warning.


-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "huberylee (via GitHub)" <gi...@apache.org>.
huberylee commented on code in PR #39389:
URL: https://github.com/apache/arrow/pull/39389#discussion_r1438365622


##########
cpp/src/arrow/array/data.h:
##########
@@ -449,7 +449,8 @@ struct ARROW_EXPORT ArraySpan {
   /// \return A span<const T> of the requested length
   template <typename T>
   util::span<const T> GetSpan(int i, int64_t length) const {
-    const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
+    [[maybe_unused]] const int64_t buffer_length =

Review Comment:
   > `ARROW_UNUSED()` looks better
   
   Will replace it with `ARROW_UNUSED()`. Thanks.



-- 
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


Re: [PR] GH-39387: [C++] Fix compile warning [arrow]

Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #39389:
URL: https://github.com/apache/arrow/pull/39389#discussion_r1438253120


##########
cpp/src/arrow/array/data.h:
##########
@@ -449,7 +449,8 @@ struct ARROW_EXPORT ArraySpan {
   /// \return A span<const T> of the requested length
   template <typename T>
   util::span<const T> GetSpan(int i, int64_t length) const {
-    const int64_t buffer_length = buffers[i].size / static_cast<int64_t>(sizeof(T));
+    [[maybe_unused]] const int64_t buffer_length =

Review Comment:
   `ARROW_UNUSED()` looks better



-- 
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