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

error: redefinition of 'cache' [related to the recently added library dragonbox.h] #1334

Open
Unike267 opened this issue Dec 23, 2024 · 6 comments

Comments

@Unike267
Copy link

Hi there!

While building a container that uses yaml-cpp, I encountered the following error:

issue-yaml-ccp

This container builds, among other things, prjxray, which relies on this project.

The build worked perfectly four days ago:

However, it is now failing:

I see that the problem is related to a recently added library called dragonbox.h.

Does anyone have any tips or insights on how to resolve this issues?

Cheers!

@jbeder
Copy link
Owner

jbeder commented Dec 23, 2024

Can you paste the error instead of a screenshot?

@Unike267
Copy link
Author

Yeah of course!

[ 10%] Building CXX object third_party/yaml-cpp/CMakeFiles/yaml-cpp.dir/src/fptostring.cpp.o
In file included from /prjxray/third_party/yaml-cpp/src/fptostring.cpp:2:
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:1392:52: error: redefinition of 'cache' with a different type: 'const array<[...], detail::stdr::size_t(max_k - min_k + 1) aka 78>' vs 'const array<[...], detail::stdr::size_t(max_k - min_k + 1)>'
            cache_holder<ieee754_binary32, Dummy>::cache;
                                                   ^
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:1346:17: note: previous declaration is here
                cache JKJ_STATIC_DATA_SECTION = {
                ^
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:2028:52: error: redefinition of 'cache' with a different type: 'const array<[...], detail::stdr::size_t(max_k - min_k + 1) aka 619>' vs 'const array<[...], detail::stdr::size_t(max_k - min_k + 1)>'
            cache_holder<ieee754_binary64, Dummy>::cache;
                                                   ^
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:1402:17: note: previous declaration is here
                cache JKJ_STATIC_DATA_SECTION = {
                ^
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4026:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4028:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4033:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4035:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4040:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4042:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4047:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4049:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4054:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4056:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4061:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4063:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
12 warnings and 2 errors generated.
make[3]: *** [third_party/yaml-cpp/CMakeFiles/yaml-cpp.dir/build.make:251: third_party/yaml-cpp/CMakeFiles/yaml-cpp.dir/src/fptostring.cpp.o] Error 1
make[3]: Leaving directory '/prjxray/build'
make[2]: *** [CMakeFiles/Makefile2:5004: third_party/yaml-cpp/CMakeFiles/yaml-cpp.dir/all] Error 2
make[2]: Leaving directory '/prjxray/build'
make[1]: *** [Makefile:149: all] Error 2
make[1]: Leaving directory '/prjxray/build'
make: *** [Makefile:44: build] Error 2

Thanks for the quick response! 😃

@jbeder
Copy link
Owner

jbeder commented Dec 23, 2024

@SGSSGene could you take a look?

@SGSSGene
Copy link
Contributor

Hi
Issue can be reproduced on godbolt: https://godbolt.org/z/noddWPhb7 but it seems to be a clang 11 issue.

@Unlike267
I see you are using clang 11.0.1, if I see correctly you have two easy options:

  1. update clang to something recent (even clang 12 would be enough)
  2. or you change -std=c++14 to -std=c++17
    This can be done cleanest by adding target_compile_features(libprjxray PUBLIC cxx_std_17) or something similar to lib/CMakeLists.txt

If possible, I would like to keep away from supporting c++14 on clang 11.

@Unike267
Copy link
Author

Hi @SGSSGene!

Wow, thank you very much for your quick response! ❤️

Great reasoning! It makes a lot of sense. I’ll apply your suggestion!

PS: I like the play on “unlike,” but it’s actually “Unike” (a combination of my name, Unai, and the Nike brand) hahah.

Cheers!

Unike267 added a commit to Unike267/Containers that referenced this issue Dec 24, 2024
According to @SGSSGene to solve the issue f4pga/prjxray#2472
Clang must be updated, in this case from 11 to 14
See jbeder/yaml-cpp#1334 for more info

Thanks to Simon Gene Gottlieb
@Unike267
Copy link
Author

Thank you very much, @SGSSGene, the issue is solved! 🥳

It is true that it now gives the following warnings:

[ 10%] Building CXX object third_party/yaml-cpp/CMakeFiles/yaml-cpp.dir/src/fptostring.cpp.o
In file included from /prjxray/third_party/yaml-cpp/src/fptostring.cpp:2:
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4026:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4028:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4033:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4035:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4040:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4042:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4047:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4049:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4054:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4056:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4061:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(...) noexcept { return false; }
                               ^
                                               const
/prjxray/third_party/yaml-cpp/src/contrib/dragonbox.h:4063:32: warning: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Wconstexpr-not-const]
                constexpr bool operator()(dummy<Policy>) noexcept {
                               ^
                                                         const
12 warnings generated.

But don't worry about that, container building works fine!

Workflow: https://github.com/Unike267/Containers/actions/runs/12485132318/job/34843498856

And container works fine!

Cheers!

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

3 participants