abseil / abseil/abseil-cpp

[Bug]: Constexpr expansion compilation error with GCC's UndefinedBehaviorSanitizer

Aperta
#1,634 14 commenti 18 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C++
Stelle
18.1k
Fork
3.2k
Merge medio
20h 36m
PR unite (30g)
1

Descrizione

### Describe the issue

When building abseil with GCC with `-fsanitize=undefined`, the following compilation error occurs:
```
/abseil/absl/container/internal/raw_hash_set.h:3364:56: in 'constexpr' expansion of 'absl::container_internal::hash_policy_traits, absl::CommandLineFlag*>, void>::get_hash_slot_fn()'
/abseil/absl/container/internal/hash_policy_traits.h:163:54: error: '(absl::container_internal::TypeErasedApplyToSlotFn > == 0)' is not a constant expression
163 | return Policy::template get_hash_slot_fn() == nullptr
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
make-4.3[4]: *** [absl/flags/CMakeFiles/flags_reflection.dir/build.make:66: absl/flags/CMakeFiles/flags_reflection.dir/reflection.cc.o] Error 1
```

This code producing the error has been introduced with commit 4c7e7c7d9.

The error does *not* occur when building with no sanitizer or when building with `-fsanitize=address` or `-fsanitize=thread`.

This seems to be a known GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71962

### Steps to reproduce the problem

```
git clone https://github.com/abseil/abseil-cpp.git
cd abseil-cpp
mkdir build
cd build
cmake -DCMAKE_CXX_FLAGS="-fsanitize=undefined" ..
make
```
Isolated expression from the method where the error occurs (`absl::container_internal::hash_policy_traits::get_hash_slot_fn()`) with `-std=gnu++17 -fsanitize=undefined`: https://godbolt.org/z/8bEazf6e5

### What version of Abseil are you using?

7bd9ff910d489658da58251de1317eb3f790a2c6

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

Ubuntu 20.04.6 LTS

### What compiler and version are you using?

GCC 9.4.0
Also tested with GCC 13.2 on linked godbolt.

### What build system are you using?

cmake 3.16.3

### Additional context

_No response_

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.