https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89881
Bug ID: 89881 Summary: Incorrect warning "-Wunneeded-internal-declaration" Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lumosimann at gmail dot com Target Milestone: --- Suppose you have a concept implementation (pre-C++17). This might be something like this: #include <utility> template <typename T, typename = void> struct check_concept : std::false_type {}; template <typename T> struct check_concept<T, std::enable_if_t< std::is_same_v<decltype(f(std::declval<T>())), int>>> : std::true_type {}; The type T fulfills the concept if there exists a function f that takes T and returns int. There may be other functions required for the concept. Now we are going to use the concept, maybe in a unittest. namespace { struct my_type {}; int f(my_type); // my_type implements the concept static_assert(check_concept<my_type>::value, ""); } This will warn about f being unneeded. Somehow it is, because it is not actually emitted, but on the hand, f is needed because we want to ensure that f fulfills the concept. Is the warning correct or not? See also https://godbolt.org/z/fROBm1