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

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

Open
kaxub opened this issue Mar 6, 2024 · 7 comments

Comments

@kaxub
Copy link

kaxub commented Mar 6, 2024

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::container_internal::FlatHashMapPolicy<std::basic_string_view<char>, absl::CommandLineFlag*>, void>::get_hash_slot_fn<absl::container_internal::StringHash>()'
/abseil/absl/container/internal/hash_policy_traits.h:163:54: error: '(absl::container_internal::TypeErasedApplyToSlotFn<absl::container_internal::StringHash, std::basic_string_view<char> > == 0)' is not a constant expression
  163 |     return Policy::template get_hash_slot_fn<Hash>() == 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 4c7e7c7.

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<Hash>()) with -std=gnu++17 -fsanitize=undefined: https://godbolt.org/z/8bEazf6e5

What version of Abseil are you using?

7bd9ff9

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

@jnooree
Copy link

jnooree commented Mar 6, 2024

Same issue here.

jnooree added a commit to seoklab/nurikit that referenced this issue Mar 6, 2024
@ptrmtrx
Copy link

ptrmtrx commented Mar 19, 2024

@derekmauro can somebody from abseil look at it please, it blocks our development. We use google quiche that uses abseil, but we build it by gcc with undefined behavior sanitizer and it results into this bug.

@jnooree
Copy link

jnooree commented Mar 19, 2024

For a temporary workaround, I used clang for sanitizer builds.

@ptrmtrx
Copy link

ptrmtrx commented Mar 19, 2024

Unfortunately, t's not an option in our environment.

@derekmauro
Copy link
Member

Sorry, this issue is not a priority for me at the moment.

@BotellaA
Copy link
Contributor

BotellaA commented Jul 8, 2024

Is there any update on this? Is it an abseil issue or a GCC issue?

@jnooree
Copy link

jnooree commented Jul 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants