Consider this C++ code:
#include <vector>
#include <numeric>
#include <inttypes.h>
int64_t sum(const std::vector<int64_t>& values) {
return std::accumulate(values.begin(), values.end(), 0);
}
I'm using mainline. When I compile this with -Wconversion I get no warning.
When I compile it with -Wconversion -Wsystem-headers I get
In file included from ../install/include/c++/4.5.0/numeric:63:0,
from /home/iant/foo1.cc:2:
../install/include/c++/4.5.0/bits/stl_numeric.h: In function _Tp
std::accumulate(_InputIterator, _InputIterator, _Tp) [with _InputIterator =
__gnu_cxx::__normal_iterator<const long long int*, std::vector<long long int>
>, _Tp = int]:
/home/iant/foo1.cc:6:55: instantiated from here
../install/include/c++/4.5.0/bits/stl_numeric.h:122:2: warning: conversion to
int from long long int may alter its value
This warning indicates a problem with user code. It is being disabled because
the template is defined in a system header. That is incorrect in this sort of
case. When a template is instantiated, we should issue warnings as
appropriate, even if the template is defined in a system header.
--
Summary: Warnings should not be disabled when instantiating
templates defined in system headers
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167