[Bug libstdc++/30463] New: [regression] -Wconversion triggers

gerald at pfeifer dot com gcc-bugzilla@gcc.gnu.org
Sun Jan 14 20:40:00 GMT 2007


Consider the following program:

  #include <vector>

  void f() {
    std::vector<int> v;

    v.push_back(1);
  }

-Wconversion now (as of 2007-01-14) triggers the following warning in
the libstdc++ headers:

/suse/gp/gcc-i686/lib/gcc/i686-suse-linux/4.3.0/../../../../include/c++/4.3.0/bits/stl_vector.h:
In destructor 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = int,
_Alloc = std::allocator<int>]':
/suse/gp/gcc-i686/lib/gcc/i686-suse-linux/4.3.0/../../../../include/c++/4.3.0/bits/stl_vector.h:199:
  instantiated from 'std::vector<_Tp, _Alloc>::vector(const _Alloc&) [with _Tp
= int, _Alloc = std::allocator<int>]'
x.cc:4:   instantiated from here
/suse/gp/gcc-i686/lib/gcc/i686-suse-linux/4.3.0/../../../../include/c++/4.3.0/bits/stl_vector.h:120:
warning: conversion to 'unsigned int' from 'int' may alter its value
/suse/gp/gcc-i686/lib/gcc/i686-suse-linux/4.3.0/../../../../include/c++/4.3.0/bits/vector.tcc:
In member function 'void std::vector<_Tp,
_Alloc>::_M_insert_aux(__gnu_cxx::__normal_iterator<typename
std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer, std::vector<_Tp,
_Alloc> >, const _Tp&) [with _Tp = int, _Alloc = std::allocator<int>]':
/suse/gp/gcc-i686/lib/gcc/i686-suse-linux/4.3.0/../../../../include/c++/4.3.0/bits/stl_vector.h:605:
  instantiated from 'void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with
_Tp = int, _Alloc = std::allocator<int>]'
x.cc:6:   instantiated from here
/suse/gp/gcc-i686/lib/gcc/i686-suse-linux/4.3.0/../../../../include/c++/4.3.0/bits/vector.tcc:295:
warning: conversion to 'unsigned int' from 'int' may alter its value

This is bad.  Our own headers should not trigger such warnings when a 
user enables them for his own code.


-- 
           Summary: [regression] -Wconversion triggers
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gerald at pfeifer dot com


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



More information about the Gcc-bugs mailing list