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

Compile error with GCC 6.3.0 #3738

Closed
asantoni opened this issue Dec 7, 2023 · 2 comments
Closed

Compile error with GCC 6.3.0 #3738

asantoni opened this issue Dec 7, 2023 · 2 comments

Comments

@asantoni
Copy link
Contributor

asantoni commented Dec 7, 2023

I ran into a compile error on GCC 6.3.0 (Debian 9). The last line is the most relevant:

/stuff/vcpkg_installed/x64-linux/include/spdlog/common.h: In function 'constexpr spdlog::string_view_t spdlog::details::to_string_view(const memory_buf_t&)':
/stuff/vcpkg_installed/x64-linux/include/spdlog/common.h:351:42: error: call to non-constexpr function 'constexpr const T* fmt::v10::detail::buffer<T>::data() const [with T = char]'
     return spdlog::string_view_t{buf.data(), buf.size()};
                                  ~~~~~~~~^~
In file included from /stuff/vcpkg_installed/x64-linux/include/fmt/format.h:49:0,
                 from /stuff/vcpkg_installed/x64-linux/include/fmt/std.h:22,
                 from /stuff/src/logger.h:10,
                 from /stuff/src/redacted.h:15,
                 from /stuff/src/redacted.cpp:1:
/stuff/vcpkg_installed/x64-linux/include/fmt/core.h:845:22: note: 'constexpr const T* fmt::v10::detail::buffer<T>::data() const [with T = char]' is not usable as a constexpr function because:
   FMT_CONSTEXPR auto data() const noexcept -> const T* { return ptr_; }
                      ^~~~
/stuff/vcpkg_installed/x64-linux/include/fmt/core.h:845:22: error: enclosing class of constexpr non-static member function 'constexpr const T* fmt::v10::detail::buffer<T>::data() const [with T = char]' is not a literal type
/stuff/vcpkg_installed/x64-linux/include/fmt/core.h:798:29: note: 'fmt::v10::detail::buffer<char>' is not literal because:
 template <typename T> class buffer {
                             ^~~~~~
/stuff/vcpkg_installed/x64-linux/include/fmt/core.h:798:29: note:   'fmt::v10::detail::buffer<char>' is not an aggregate, does not have a trivial default constructor, and has no constexpr constructor that is not a copy or move constructor

This issue is similar to #3096

My patch that fixes this compile error is:

diff --git a/include/fmt/core.h b/include/fmt/core.h
index 1fe1388..f97c630 100755
--- a/include/fmt/core.h
+++ b/include/fmt/core.h
@@ -804,7 +804,7 @@ template <typename T> class buffer {
  protected:
   // Don't initialize ptr_ since it is not accessed to save a few cycles.
   FMT_MSC_WARNING(suppress : 26495)
-  buffer(size_t sz) noexcept : size_(sz), capacity_(sz) {}
+  FMT_CONSTEXPR buffer(size_t sz) noexcept : size_(sz), capacity_(sz) {}

   FMT_CONSTEXPR20 buffer(T* p = nullptr, size_t sz = 0, size_t cap = 0) noexcept
       : ptr_(p), size_(sz), capacity_(cap) {}

I'm not sure how to get a reproducer in godbolt. My code seems to be be blowing up on:

#include <fmt/std.h>

Full compiler version string is:

g++ --version
g++ (Debian 6.3.0-18+deb9u1) 6.3.0 20170516

Thanks!

@asantoni asantoni changed the title Compile error with GCC 6.9.0 Compile error with GCC 6.3.0 Dec 7, 2023
@vitaut
Copy link
Contributor

vitaut commented Dec 7, 2023

Could you submit a PR?

@asantoni
Copy link
Contributor Author

asantoni commented Dec 8, 2023

No problem, pull request is open:
#3743

Thanks for your consideration!

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

2 participants