Here's an annoying regression:
-----------------------------
struct S {                                                                      
    typedef double value_type;                                                  
};                                                                              


template <typename T> struct Traits {                                           
    typedef const typename T::value_type dereference_type;                      
};                                                                              

template <class BlockVectorType> struct ConstIterator {                         
    typedef typename Traits<BlockVectorType>::dereference_type
dereference_type;                                                  

    dereference_type operator * () const  { return 0; }                         
};                                                                              

template class ConstIterator<S>;
---------------------

For this, we get:

deal.II/lac> g++ -W -Wall -c a.cc        
a.cc: In instantiation of 'ConstIterator<S>':
a.cc:16:   instantiated from here
a.cc:13: warning: type qualifiers ignored on function return type

We didn't use to produce this warning. I also think it's hard to avoid:
if the class S would declare its value_type as a reference, then the
addition of the 'const' in the Traits class would matter; here, it doesn't,
but that's only because of chance.

What's worse is that the warning is also inconsistent: if we replace
    template <class BlockVectorType> struct ConstIterator {                     
        typedef typename Traits<BlockVectorType>::dereference_type
dereference_type;                                                  

by

    template <class BlockVectorType> struct ConstIterator {                     
      typedef const typename BlockVectorType::value_type dereference_type;      

then the warning goes away despite the fact that the actual types are
exactly the same. Weird.

W.


-- 
           Summary: [4.3/4.4 regression] bogus "type qualifiers ignored"
                    warning
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36052

Reply via email to