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

            Bug ID: 82269
           Summary: -Wignored-qualifiers should not trigger on templated
                    code
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sgunderson at bigfoot dot com
  Target Milestone: ---

Hi,

When compiling MySQL with GCC 8.0.0 20170917, I get

In file included from ../include/my_byteorder.h:53:0,
                 from ../include/m_ctype.h:29,
                 from ../sql/parse_tree_helpers.h:24,
                 from ../unittest/gunit/opt_ref-t.cc:23:
../include/template_utils.h: In instantiation of 'T pointer_cast(void*) [with T
= unsigned char* const]':
../sql/sql_optimizer.cc:9973:60:   required from here
../include/template_utils.h:70:10: warning: type qualifiers ignored on cast
result type [-Wignored-qualifiers]
   return static_cast<T>(p);
          ^~~~~~~~~~~~~~~~~

I think this is a bit too aggressive. The function in question reads

template<typename T>
inline T pointer_cast(void *p)
{
  return static_cast<T>(p);
}

Sure, it's possible to put std::remove_cv_t around the type, but should it
really be needed?

Reply via email to