abseil / abseil/abseil-cpp

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

Open
#1,843 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
18.1k
Forks
3.2k
Avg merge
20h 36m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.