google / google/googlesql

Build error on Big Endian

Open
#118 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
2.6k
Forks
260
PR merge metrics
No merged PRs in 30d

Description

Hi,

While building tfx-bsl which needs ZetaSQL on big endian, observed below error:
```
external/com_google_zetasql/zetasql/common/multiprecision_int_impl.h:317:33: note: candidate: template std::array::Uint, n1> zetasql::multiprecision_int_impl::Convert(const std::array::Uint, n2>&, bool)
inline std::array, n1> Convert(const std::array, n2>& src,
^~~~~~~
external/com_google_zetasql/zetasql/common/multiprecision_int_impl.h:317:33: note: template argument deduction/substitution failed:
external/com_google_zetasql/zetasql/common/multiprecision_int_impl.h:565:49: note: candidate expects 2 arguments, 1 provided
Array32 dividend32 = Convert<32, n * 2, 64, n>(dividend);
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
external/com_google_zetasql/zetasql/common/multiprecision_int_impl.h:570:42: error: no matching function for call to 'Convert<64, 2, 32, (2 * 2)>(Array32&)'
*quotient = Convert<64, n, 32, n * 2>(quotient32);
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
```

This is resolved with below patch:
```
diff --git a/zetasql/common/multiprecision_int_impl.h b/zetasql/common/multiprecision_int_impl.h
index 55ce01a..52d7c02 100644
--- a/zetasql/common/multiprecision_int_impl.h
+++ b/zetasql/common/multiprecision_int_impl.h
@@ -315,7 +315,7 @@ inline void Copy(const Uint* src, int src_size, Uint* dest,
// allow_optimization is used only for testing.
template
inline std::array, n1> Convert(const std::array, n2>& src,
- bool negative) {
+ bool negative = false) {
std::array, n1> res;
Uint extension = negative ? ~Uint{0} : 0;
#ifndef ABSL_IS_BIG_ENDIAN
```

As contributions are not allowed via PR, could someone help in reviewing and fixing the issue in source code?

Contributor guide

Open the contributing guide

Research direction

Start in zetasql/common/multiprecision_int_impl.h at the Convert template and its calls around lines 565 and 570. Reproduce the tfx-bsl build on a big-endian target, then verify that the reported template deduction errors are gone and the multiprecision code still builds successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.