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

GCC14 warning for subobject linkage #4368

Open
dinomight opened this issue Feb 26, 2025 · 2 comments
Open

GCC14 warning for subobject linkage #4368

dinomight opened this issue Feb 26, 2025 · 2 comments

Comments

@dinomight
Copy link
Contributor

While messing around with compiling {fmt}, I came across this warning when building with GCC14. This warning is not generated under GCC13. I've also noticed that the PR actions don't include GCC14 or some of the more modern Clang compilers. Do those need to be added? I'll likely do some digging into this warning and may propose a PR later for it, if I'm able to understand it. Wanted to make sure this was documented.

In file included from /mnt/development/fmt/include/fmt/ranges.h:20,
                 from /mnt/development/fmt/test/ranges-test.cc:8:
/mnt/development/fmt/include/fmt/format.h: In instantiation of ‘struct fmt::v11::formatter<views_filter_view_test::codec_mask, char, void>’:
/mnt/development/fmt/include/fmt/base.h:1101:52:   required by substitution of ‘template<class T> struct fmt::v11::detail::use_format_as_member<T, std::integral_constant<bool, std::is_arithmetic<typename std::remove_cv<typename std::remove_reference<decltype (fmt::v11::formatter<T>::format_as(declval<const T&>()))>::type>::type>::value> > [with T = views_filter_view_test::codec_mask]’
 1101 |     remove_cvref_t<decltype(formatter<T>::format_as(std::declval<const T&>()))>;
      |                             ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/development/fmt/include/fmt/base.h:1124:47:   required by substitution of ‘template<class T, typename std::enable_if<std::integral_constant<bool, (((((((std::is_class<T>::value || std::is_enum<_Tp>::value) || std::is_union<T>::value) || std::is_array<T>::value) && (! fmt::v11::detail::has_to_string_view<T>::value)) && (! fmt::v11::detail::is_named_arg<T>::value)) && (! fmt::v11::detail::use_format_as<T>::value)) && (! fmt::v11::detail::use_format_as_member<typename std::remove_const<_Tp>::type, std::integral_constant<bool, true> >::value))>::value, int>::type <anonymous> > static fmt::v11::conditional_t<((bool)has_formatter<T, char>()), T&, void> fmt::v11::detail::type_mapper<char>::map(T&) [with T = views_filter_view_test::codec_mask; typename std::enable_if<std::integral_constant<bool, (((((((std::is_class<T>::value || std::is_enum<_Tp>::value) || std::is_union<T>::value) || std::is_array<T>::value) && (! fmt::v11::detail::has_to_string_view<T>::value)) && (! fmt::v11::detail::is_named_arg<T>::value)) && (! fmt::v11::detail::use_format_as<T>::value)) && (! fmt::v11::detail::use_format_as_member<typename std::remove_const<_Tp>::type, std::integral_constant<bool, true> >::value))>::value, int>::type <anonymous> = <missing>]’
 1124 |                   !use_format_as<T>::value && !use_format_as_member<U>::value>;
      |                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mnt/development/fmt/include/fmt/base.h:1197:57:   required by substitution of ‘template<class T, class Char> using fmt::v11::detail::mapped_type_constant = fmt::v11::detail::type_constant<decltype (fmt::v11::detail::type_mapper<Char>::map(declval<T&>())), Char> [with T = views_filter_view_test::codec_mask&; Char = char]’
 1197 | using mapped_t = decltype(detail::type_mapper<Char>::map(std::declval<T&>()));
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/mnt/development/fmt/include/fmt/base.h:1676:47:   required from ‘constexpr fmt::v11::detail::format_string_checker<Char, NUM_ARGS, NUM_NAMED_ARGS, DYNAMIC_NAMES>::format_string_checker(fmt::v11::basic_string_view<Char>, fmt::v11::detail::arg_pack<T ...>) [with T = {views_filter_view_test::codec_mask&}; Char = char; int NUM_ARGS = 1; int NUM_NAMED_ARGS = 0; bool DYNAMIC_NAMES = false]’
 1676 |       : types_{mapped_type_constant<T, Char>::value...},
      |                                               ^~~~~
/mnt/development/fmt/include/fmt/base.h:2708:57:   required from here
 2708 |     if (FMT_USE_CONSTEVAL) parse_format_string<char>(s, checker(s, arg_pack()));
      |                                                         ^~~~~~~~~~~~~~~~~~~~~~
/mnt/development/fmt/test/ranges-test.cc:747:5:   in ‘constexpr’ expansion of ‘fmt::v11::fstring<views_filter_view_test::codec_mask&>("{}")’
/mnt/development/fmt/include/fmt/format.h:3810:8: error: ‘fmt::v11::formatter<views_filter_view_test::codec_mask, char, void>’ has a base ‘fmt::v11::formatter<std::ranges::filter_view<std::ranges::ref_view<const std::array<int, 4> >, views_filter_view_test::format_as(codec_mask)::<lambda(auto:38)> >, char, void>’ which has internal linkage [-Werror=subobject-linkage]
 3810 | struct formatter<T, Char, void_t<detail::format_as_result<T>>>
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@vitaut
Copy link
Contributor

vitaut commented Feb 28, 2025

Please provide a godbolt repro.

@dinomight
Copy link
Contributor Author

I tried to snip out the test code that's causing the problem, but it isn't reproducing over on godbolt. This is what I tried: https://godbolt.org/z/7xWKbbxPv

I'm not sure if that means it has something to do with the test framework or the fact that there's more content in the compilation unit. I can confirm that removing the test entirely resolves the issues. I can also confirm that removing things from the asserts also doesn't solve it. Setting up godbolt as a gtest setup doesn't replicate either: https://godbolt.org/z/coKTTx7Yb

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