public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107492] New: Unhelpful -Wignored-qualifiers warning in template specialization
@ 2022-11-01 11:16 redi at gcc dot gnu.org
  2022-11-01 15:40 ` [Bug c++/107492] " mpolacek at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-01 11:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107492
           Summary: Unhelpful -Wignored-qualifiers warning in template
                    specialization
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

GCC warns about this with -Wextra:

template<typename T> struct S { };
template<> struct S<void(*)()> { };
template<> struct S<const void(*)()> { };

template<typename T, typename U> constexpr bool is_same_v = false;
template<typename T> constexpr bool is_same_v<T, T> = true;

static_assert( ! is_same_v< void(*)(), const void(*)() > );


spec.cc:3:21: warning: type qualifiers ignored on function return type
[-Wignored-qualifiers]
    3 | template<> struct S<const void(*)()> { };
      |                     ^~~~~
spec.cc:8:40: warning: type qualifiers ignored on function return type
[-Wignored-qualifiers]
    8 | static_assert( ! is_same_v< void(*)(), const void(*)() > );
      |                                        ^~~~~


The warning is wrong, the qualifiers are not ignored here. The two types are
distinct, as shown by the fact that the explicit specializations are not
redefinitions of each other, and the static assert passes.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-28 22:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-01 11:16 [Bug c++/107492] New: Unhelpful -Wignored-qualifiers warning in template specialization redi at gcc dot gnu.org
2022-11-01 15:40 ` [Bug c++/107492] " mpolacek at gcc dot gnu.org
2022-11-01 16:52 ` mpolacek at gcc dot gnu.org
2022-11-02 12:56 ` cvs-commit at gcc dot gnu.org
2022-11-03 19:05 ` jason at gcc dot gnu.org
2022-11-03 20:11 ` redi at gcc dot gnu.org
2022-11-15 22:44 ` cvs-commit at gcc dot gnu.org
2022-11-15 22:45 ` mpolacek at gcc dot gnu.org
2022-11-15 22:47 ` redi at gcc dot gnu.org
2022-11-28 22:21 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).