abseil / abseil/abseil-cpp

[Bug]: `FixedArray` triggers `-Wfree-nonheap-object` warnings in LTO builds

オープン
#1,843 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
18.1k
フォーク
3.2k
平均マージ
20時間 36分
マージ済み PR(30日)
1

説明

### Describe the issue

Using GCC 14.2.1 we see the following warnings:

```console
/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:29: note: a type with different bases is defined in another translation unit
29 | struct evaluator >
[788/969] Linking CXX executable bin/numeric_diff_cost_function_test
In member function ‘deallocate’,
inlined from ‘deallocate’ at /usr/include/c++/14.2.1/bits/alloc_traits.h:513:23,
inlined from ‘__dt_base ’ at /home/sergiu/Projects/ceres-solver/third_party/abseil-cpp/absl/container/fixed_array.h:481:36,
inlined from ‘__dt_base ’ at /home/sergiu/Projects/ceres-solver/third_party/abseil-cpp/absl/container/fixed_array.h:174:3,
inlined from ‘EvaluateJacobianForParameterBlock’ at /home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:170:3,
inlined from ‘Apply’ at /home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:462:52,
inlined from ‘Evaluate’ at /home/sergiu/Projects/ceres-solver/include/ceres/numeric_diff_cost_function.h:262:47:
/usr/include/c++/14.2.1/bits/new_allocator.h:172:33: warning: ‘operator delete’ called on unallocated object ‘residual_array’ [-Wfree-nonheap-object]
172 | _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n));
| ^
/home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h: In member function ‘Evaluate’:
/home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:129:30: note: declared here
129 | absl::FixedArray residual_array(num_residuals_internal);
| ^
In member function ‘deallocate’,
inlined from ‘deallocate’ at /usr/include/c++/14.2.1/bits/alloc_traits.h:513:23,
inlined from ‘__dt_base ’ at /home/sergiu/Projects/ceres-solver/third_party/abseil-cpp/absl/container/fixed_array.h:481:36,
inlined from ‘__dt_base ’ at /home/sergiu/Projects/ceres-solver/third_party/abseil-cpp/absl/container/fixed_array.h:174:3,
inlined from ‘EvaluateJacobianForParameterBlock’ at /home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:170:3,
inlined from ‘Apply’ at /home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:462:52,
inlined from ‘Evaluate’ at /home/sergiu/Projects/ceres-solver/include/ceres/numeric_diff_cost_function.h:262:47:
/usr/include/c++/14.2.1/bits/new_allocator.h:172:33: warning: ‘operator delete’ called on unallocated object ‘residual_array’ [-Wfree-nonheap-object]
172 | _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n));
| ^
/home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h: In member function ‘Evaluate’:
/home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:129:30: note: declared here
129 | absl::FixedArray residual_array(num_residuals_internal);
|
```

### Steps to reproduce the problem

1. Construct `absl::FixedArray a(n)`.
2. Compile using `-flto=auto`.

### What version of Abseil are you using?

The `lts_2024_01_16` branch.

### What operating system and version are you using?

ArchLinux

### What compiler and version are you using?

GCC 14.2.1

### What build system are you using?

cmake version 3.31.5

### Additional context

_No response_

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。