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; 15+ 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] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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 ` pinskia at gcc dot gnu dot org
2010-02-24 19:37 ` pinskia at gcc dot gnu dot org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-02-24 19:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2010-02-24 19:35 -------
There was a bug asking the opposite way IIRC.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-02-24 19:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2010-02-24 19:37 -------
PR 36760 is an example where it was asking the opposite way. I thought there
was more than that bug though.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-02-24 19:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2010-02-24 19:38 -------
Found it, PR 30500 was the exact bug which changed this behavior :).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (2 preceding siblings ...)
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
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-02-24 19:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pinskia at gcc dot gnu dot org 2010-02-24 19:41 -------
>This warning indicates a problem with user code.
Or is it? Since long long does not exist in C++03 :).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (3 preceding siblings ...)
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
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: ian at airs dot com @ 2010-02-24 20:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from ian at airs dot com 2010-02-24 20:56 -------
The use of long long is irrelevant here.
PR 30500 appears to be about non-dependent types. So let's make this bug be
about dependent types. I know that makes it harder, but it seems to me to be
the right thing to do.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (4 preceding siblings ...)
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
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-02-24 21:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from paolo dot carlini at oracle dot com 2010-02-24 21:43 -------
Out of curiosity: what happens with ICC? (normally installed with the system
libstdc++ as C++ run-time)?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (5 preceding siblings ...)
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
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: ian at airs dot com @ 2010-02-24 22:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from ian at airs dot com 2010-02-24 22:33 -------
I don't know about icc, but see also http://llvm.org/PR6418 .
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (6 preceding siblings ...)
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
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-02-24 22:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from paolo dot carlini at oracle dot com 2010-02-24 22:47 -------
ICC doesn't warn (emits another spurious warning, by the way, which has nothing
to do with this issue). More generally, compilers using the EDG front-end, eg,
Comeau, apparently do not warn at the most strict diagnostic level. Likewise
SunStudio. I'm not saying we cannot do better, just, seems a pretty
sophisticated goal, and really, in my opinion, we should be *very* careful with
false positive, because normally it's unacceptable to emit warnings about
internal details of the implementation.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (7 preceding siblings ...)
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
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-02-24 22:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from manu at gcc dot gnu dot org 2010-02-24 22:52 -------
(In reply to comment #7)
> I don't know about icc, but see also http://llvm.org/PR6418 .
Out of curiosity. Is it really the output of g++ so messy compared with clang,
or is it an artifact of copy+paste from the console?
It looks totally broken (printing "In function" after filename?)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (8 preceding siblings ...)
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
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-02-24 22:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from pinskia at gcc dot gnu dot org 2010-02-24 22:56 -------
looks like the terminial is wrapping funny.
In file included from
/home/apinski/local-gcc/lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/numeric:62:0,
from t.cc:2:
/home/apinski/local-gcc/lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../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 int*, std::vector<long
int> >, _Tp = int]':
t.cc:6:57: instantiated from here
/home/apinski/local-gcc/lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../include/c++/4.5.0/bits/stl_numeric.h:123:2:
warning: conversion to 'int' from 'long int' may alter its value
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (9 preceding siblings ...)
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
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-02-24 23:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from pinskia at gcc dot gnu dot org 2010-02-24 23:00 -------
Note this is much better than what it was in 4.3 where std::vector<long> was
shown as:
std::vector<long int, std::allocator<long int> > >
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (10 preceding siblings ...)
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
13 siblings, 0 replies; 15+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-02-24 23:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from manu at gcc dot gnu dot org 2010-02-24 23:20 -------
(In reply to comment #11)
> Note this is much better than what it was in 4.3 where std::vector<long> was
> shown as:
> std::vector<long int, std::allocator<long int> > >
That part looks better GCC, however, in the context information, the clang
output is far clearer.
Why we print the file with no location info just above the "In function"?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (11 preceding siblings ...)
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
13 siblings, 0 replies; 15+ messages in thread
From: ian at airs dot com @ 2010-02-25 0:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from ian at airs dot com 2010-02-25 00:17 -------
Paolo: It is definitely a complicated case, the concern about false positives
is entirely valid. This leads us to introducing more command line options,
plus getting #pragma GCC diagnostic to work. I'm not sure what the best
solution is.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/43167] Warnings should not be disabled when instantiating templates defined in system headers
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
` (12 preceding siblings ...)
2010-02-25 0:17 ` ian at airs dot com
@ 2010-04-21 19:02 ` redi at gcc dot gnu dot org
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-04-21 19:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from redi at gcc dot gnu dot org 2010-04-21 19:02 -------
Bug 43820 shows cases where libstdc++ was *relying* on the front-end issuing
warnings about calling delete with a pointer to incomplete types. I'm going to
change the library code to handle it instead, but it's an extra data point
related to this bug
--
redi at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |redi at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43167
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2010-04-21 19:02 UTC | newest]
Thread overview: 15+ 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
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).