[Bug]: std::move of empty absl::InlinedVector can result in Werror=uninitialized in gcc 12.2 with -O3
- Linguagem predominante
- C++
- Estrelas
- 18.1k
- Forks
- 3.2k
- Merge médio
- 20h 36min
- PRs com merge (30d)
- 1
Descrição
### Describe the issue
Issue was hit when unrelated changes somehow changed layout of some struct causing the optimized build -O3 -Wall -Werror to fail with error:
```/opt/compiler-explorer/libs/abseil/absl/container/internal/inlined_vector.h:522:5: error: 'test_obj1.absl::InlinedVector >::storage_.absl::inlined_vector_internal::Storage >::data_' is used uninitialized [-Werror=uninitialized]```
### Steps to reproduce the problem
It's not easy to reproduce but somehow in google test framework you can hit it rather easy:
```c++
TEST(TestCompile, trigger) {
absl::InlinedVector test_obj1{};
absl::InlinedVector test_obj2{std::move(test_obj1)};
EXPECT_EQ(test_obj2.size(), 0);
}
```
https://godbolt.org/z/4aMTYbWKG
Not all gcc versions will report it but 12 and 13 do and you will need optimization.
### What version of Abseil are you using?
Seen in all 20220623 and 20240722. (and version that godbolt uses)
### What operating system and version are you using?
Should not really mater here:
```
$ uname -a
Linux 5007575312c8 5.15.0-102-generic #112-Ubuntu SMP Tue Mar 5 16:50:32 UTC 2024 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
```
### What compiler and version are you using?
```
$ /usr/bin/x86_64-linux-gnu-g++-12 --version
x86_64-linux-gnu-g++-12 (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```
### What build system are you using?
```
$ cmake --version
cmake version 3.25.1
```
### Additional context
It's unclear if this is a compiler bug or technical correct as the `MemcpyFrom` function literately copies the uninitialized `data_` union.
https://github.com/abseil/abseil-cpp/blob/45c456bd276259a972cb3ab2a0f3e0cd75566029/absl/container/internal/inlined_vector.h#L522
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.