public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43167]  New: Warnings should not be disabled when instantiating templates defined in system headers
@ 2010-02-24 19:34 ian at airs dot com
  2010-02-24 19:35 ` [Bug c++/43167] " pinskia at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 17+ messages in thread
From: ian at airs dot com @ 2010-02-24 19:34 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1589 bytes --]

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


^ permalink raw reply	[flat|nested] 17+ messages in thread
[parent not found: <bug-43167-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2024-03-05 14:29 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-24 19:34 [Bug c++/43167] New: Warnings should not be disabled when instantiating templates defined in system headers ian at airs dot com
2010-02-24 19:35 ` [Bug c++/43167] " pinskia at gcc dot gnu dot org
2010-02-24 19:37 ` pinskia at gcc dot gnu dot org
2010-02-24 19:39 ` pinskia at gcc dot gnu dot org
2010-02-24 19:42 ` pinskia at gcc dot gnu dot org
2010-02-24 20:56 ` ian at airs dot com
2010-02-24 21:43 ` paolo dot carlini at oracle dot com
2010-02-24 22:33 ` ian at airs dot com
2010-02-24 22:47 ` paolo dot carlini at oracle dot com
2010-02-24 22:52 ` manu at gcc dot gnu dot org
2010-02-24 22:56 ` pinskia at gcc dot gnu dot org
2010-02-24 23:00 ` pinskia at gcc dot gnu dot org
2010-02-24 23:20 ` manu at gcc dot gnu dot org
2010-02-25  0:17 ` ian at airs dot com
2010-04-21 19:02 ` redi at gcc dot gnu dot org
     [not found] <bug-43167-4@http.gcc.gnu.org/bugzilla/>
2020-06-19 19:10 ` redi at gcc dot gnu.org
2024-03-05 14:29 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).