This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] libstdc++/12854
llewelly@xmission.com writes:
> Benjamin Kosnik <bkoz@redhat.com> writes:
>
> > >Why doesn't
> > >
> > >#pragma GCC system_header
> > >
> > >address this issue?
> >
> > what do you mean? Why does -Weffc++ appear to ignore this pragma?
>
> No - I meant the opposite. I'm sorry I was unclear. This:
[snip]
>
> generates no warnings when compiled with -Weffc++, using gcc 3.4 or
> 3.5 20040502 .
>
> That is, ITSM the pragma already solved the issue. Or I am
> misunderstanding something.
Here is what I missed:
#include <vector>
#include <algorithm>
struct C{int a;};
bool comp(C const& lhs, C const& rhs){return lhs.a < rhs.a;}
int main()
{
std::vector<C> vecC;
std::sort(vecC.begin(),vecC.end(),comp);
}
gives these warnings:
cd /home/llewelly/llewelly/cc_moderated/
/usr/local/gcc-3.5-20040502/bin/g++-3.5-20040502 -Wall -Weffc++
+mich.cc
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/allocator.h:
+In instantiation of 'std::allocator<C>':
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:80:
+instantiated from 'std::_Vector_base<C, std::allocator<C>
+>::_Vector_impl'
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:113:
+instantiated from 'std::_Vector_base<C, std::allocator<C> >'
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:148:
+instantiated from 'std::vector<C, std::allocator<C> >'
mich.cc:10: instantiated from here
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/allocator.h:81:
+warning: base class 'class __gnu_cxx::new_allocator<C>' has a
+non-virtual destructor
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:
+In instantiation of 'std::_Vector_base<C, std::allocator<C>
+>::_Vector_impl':
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:113:
+instantiated from 'std::_Vector_base<C, std::allocator<C> >'
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:148:
+instantiated from 'std::vector<C, std::allocator<C> >'
mich.cc:10: instantiated from here
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:80:
+warning: base class 'class std::allocator<C>' has a non-virtual
+destructor
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:80:
+warning: 'struct std::_Vector_base<C, std::allocator<C>
+>::_Vector_impl' has pointer data members
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:80:
+warning: but does not override 'std::_Vector_base<C,
+std::allocator<C> >::_Vector_impl(const std::_Vector_base<C,
+std::allocator<C> >::_Vector_impl&)'
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:80:
+warning: or 'operator=(const std::_Vector_base<C, std::allocator<C>
+>::_Vector_impl&)'
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:
+In instantiation of 'std::vector<C, std::allocator<C> >':
mich.cc:10: instantiated from here
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_vector.h:148:
+warning: base class 'struct std::_Vector_base<C, std::allocator<C> >'
+has a non-virtual destructor
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_iterator.h:
+In instantiation of '__gnu_cxx::__normal_iterator<C*, std::vector<C,
+std::allocator<C> > >':
mich.cc:11: instantiated from here
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_iterator.h:587:
+warning: 'class __gnu_cxx::__normal_iterator<C*, std::vector<C,
+std::allocator<C> > >' has pointer data members
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_iterator.h:587:
+warning: but does not override '__gnu_cxx::__normal_iterator<C*,
+std::vector<C, std::allocator<C> > >(const
+__gnu_cxx::__normal_iterator<C*, std::vector<C, std::allocator<C> >
+>&)'
/usr/local/gcc-3.5-20040502/lib/gcc/i386-unknown-freebsd5.2/3.5.0/include/c++/bits/stl_iterator.h:587:
+warning: or 'operator=(const __gnu_cxx::__normal_iterator<C*,
+std::vector<C, std::allocator<C> > >&)'
But it seems to me this is a bug in #pragma GCC system_header, not in libstdc++.