https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118458

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #8)
> (In reply to Stephen Berry from comment #7)
> > I should clarify that GCC doesn't appear to emit this warning after GCC13.
> > So, in this case I was looking for a solution for older versions of GCC.
> > This request was written generically, so that the issue could be avoided in
> > the future for warnings that developers want to disable.
> 
> There is no solution for older versions of GCC since it won't be changed.

Also I tried with GCC 10, 11 and 12 and none of them warn for me either:
```
#include <concepts>
#include <cstddef>
#include <string_view>
namespace glz
{
   namespace detail
   {
      struct any_t final
      {
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
         template <class T>
            requires(!std::same_as<T, const char*> && !std::same_as<T,
std::nullptr_t>)
         [[maybe_unused]] constexpr operator T() const;
#pragma clang diagnostic pop
#elif defined(_MSC_VER)
         template <class T>
            requires(!std::same_as<T, const char*> && !std::same_as<T,
std::nullptr_t>)
         [[maybe_unused]] constexpr operator T() const;
#else
//#pragma GCC diagnostic push
//#pragma GCC diagnostic ignored "-Wmissing-declarations"
         template <class T>
            requires(!std::same_as<T, const char*> && !std::same_as<T,
std::nullptr_t>)
         [[maybe_unused]] constexpr operator T() const;
//#pragma GCC diagnostic pop
#endif

         [[maybe_unused]] constexpr operator std::string_view() const { return
{}; }
      };

      template <class T, class... Args>
         requires(std::is_aggregate_v<std::remove_cvref_t<T>>)
      inline constexpr auto count_members = [] {
         using V = std::remove_cvref_t<T>;
         if constexpr (requires { V{Args{}..., any_t{}}; }) {
            return count_members<V, Args..., any_t>;
         }
         else {
            return sizeof...(Args);
         }
      }();

      constexpr size_t max_pure_reflection_count = 128;
   }

template <class T, int N = detail::count_members<T>>
constexpr int f()
{
        return N;
}

}


struct f1{
  int t;
  int tt;
};

int h = glz::f<f1>();
```

Reply via email to