Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++] error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'const int' .... #37735

Closed
ghost opened this issue Sep 15, 2023 · 3 comments · Fixed by #38004

Comments

@ghost
Copy link

ghost commented Sep 15, 2023

Describe the bug, including details regarding any error messages, version, and platform.

New to al lthe stuff compiling.
Running FreeBSD 13.2-RELEASE-p1 trying to install pyarrow and i was following https://arrow.apache.org/docs/developers/python.html#using-system-and-bundled-dependencies .
on the step of make -j4 encountered this error.
Tried just to use "make" same problem , tried "make clean && make" same issue.

[20%] Building CXX object src/arrow/CMakeFiles/arrow_objlib.dir/util/logging.cc.o
`/home/evo/arrow/src/arrow/util/logging.cc:97:23: **error:** implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'const int' [-Werror,-Wshorten-64-to-32]
    const int calls = backtrace(buffer, static_cast<int>(sizeof(buffer) / sizeof(void*)));
1 error generated.
*** Error code1
Stop.
make[2]: stopped in /usr/home/evo/arrow/cpp/build
*** Error code 1

As im no C guy, checked actuall file which turs to my error:

void* buffer[255];
  const int calls = backtrace(buffer, static_cast<int>(sizeof(buffer) / sizeof(void*)));
backtrace_symbol_fd(buffer,calls, 1);

Component(s)

C++, Python

@js8544
Copy link
Collaborator

js8544 commented Sep 15, 2023

Since you are building manually, I assume you can change the source code. Can you update the line to

const int calls = static_cast<int>(backtrace(buffer, static_cast<int>(sizeof(buffer) / sizeof(void*))));

and then try again?

@ghost
Copy link
Author

ghost commented Sep 15, 2023

Thank You !
Worked like a charm !

@ghost
Copy link
Author

ghost commented Sep 15, 2023

Ver ystrange, can it be that pyarrow was not instaleld correctly ? it states:

ImportError while loading conftest '/usr/home/evo/arrow/python/pyarrow/conftest.py'.
pyarrow/__init__.py:65: in <module>
    import pyarrow.lib as _lib
E   ImportError: Shared object "libarrow_dataset.so.1400" not found, required by "lib.cpython-39.so"

@kou kou changed the title error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'const int' .... [C++] error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'const int' .... Sep 15, 2023
kou added a commit to kou/arrow that referenced this issue Oct 4, 2023
It's caused by `backtrace()` and `backtrace_symbols_fd()` signatures
are different on Linux and FreeBSD (`int` vs `size_t`).

Linux:

```c
extern int backtrace (void **__array, int __size) __nonnull ((1));
extern void backtrace_symbols_fd (void *const *__array, int __size, int __fd)
     __THROW __nonnull ((1));
```

FreeBSD:

```c
size_t backtrace(void **, size_t);
int backtrace_symbols_fd(void *const *, size_t, int);
```

We can use `auto` to ignore the difference.
kou added a commit that referenced this issue Oct 10, 2023
### Rationale for this change

It's caused by `backtrace()` and `backtrace_symbols_fd()` signatures are different on Linux and FreeBSD (`int` vs `size_t`).

Linux:

```c
extern int backtrace (void **__array, int __size) __nonnull ((1));
extern void backtrace_symbols_fd (void *const *__array, int __size, int __fd)
     __THROW __nonnull ((1));
```

FreeBSD:

```c
size_t backtrace(void **, size_t);
int backtrace_symbols_fd(void *const *, size_t, int);
```

### What changes are included in this PR?

Use `auto` to ignore the difference.

### Are these changes tested?

Yes on FreeBSD 12.

### Are there any user-facing changes?

No.
* Closes: #37735

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
@kou kou added this to the 14.0.0 milestone Oct 10, 2023
JerAguilon pushed a commit to JerAguilon/arrow that referenced this issue Oct 23, 2023
…pache#38004)

### Rationale for this change

It's caused by `backtrace()` and `backtrace_symbols_fd()` signatures are different on Linux and FreeBSD (`int` vs `size_t`).

Linux:

```c
extern int backtrace (void **__array, int __size) __nonnull ((1));
extern void backtrace_symbols_fd (void *const *__array, int __size, int __fd)
     __THROW __nonnull ((1));
```

FreeBSD:

```c
size_t backtrace(void **, size_t);
int backtrace_symbols_fd(void *const *, size_t, int);
```

### What changes are included in this PR?

Use `auto` to ignore the difference.

### Are these changes tested?

Yes on FreeBSD 12.

### Are there any user-facing changes?

No.
* Closes: apache#37735

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
loicalleyne pushed a commit to loicalleyne/arrow that referenced this issue Nov 13, 2023
…pache#38004)

### Rationale for this change

It's caused by `backtrace()` and `backtrace_symbols_fd()` signatures are different on Linux and FreeBSD (`int` vs `size_t`).

Linux:

```c
extern int backtrace (void **__array, int __size) __nonnull ((1));
extern void backtrace_symbols_fd (void *const *__array, int __size, int __fd)
     __THROW __nonnull ((1));
```

FreeBSD:

```c
size_t backtrace(void **, size_t);
int backtrace_symbols_fd(void *const *, size_t, int);
```

### What changes are included in this PR?

Use `auto` to ignore the difference.

### Are these changes tested?

Yes on FreeBSD 12.

### Are there any user-facing changes?

No.
* Closes: apache#37735

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
dgreiss pushed a commit to dgreiss/arrow that referenced this issue Feb 19, 2024
…pache#38004)

### Rationale for this change

It's caused by `backtrace()` and `backtrace_symbols_fd()` signatures are different on Linux and FreeBSD (`int` vs `size_t`).

Linux:

```c
extern int backtrace (void **__array, int __size) __nonnull ((1));
extern void backtrace_symbols_fd (void *const *__array, int __size, int __fd)
     __THROW __nonnull ((1));
```

FreeBSD:

```c
size_t backtrace(void **, size_t);
int backtrace_symbols_fd(void *const *, size_t, int);
```

### What changes are included in this PR?

Use `auto` to ignore the difference.

### Are these changes tested?

Yes on FreeBSD 12.

### Are there any user-facing changes?

No.
* Closes: apache#37735

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants