[Bug c++/30500] New: pragma GCC system_header vs templates
pcarlini at suse dot de
gcc-bugzilla@gcc.gnu.org
Thu Jan 18 16:26:00 GMT 2007
I don't think we have an open PR for this "well known" issue so... As you can
see, in the example below, the pragma is totally ineffective with templates,
even when the involved types are non dependent.
By the way, sad to say that, but the way ICC implements the GCC pragma for
compatibility sake is, once more, better than the original: no warning from ICC
(-Wall on ICC as a switch, excellent warnings without the pragma).
paolo:~/Work> more test.h
#pragma GCC system_header
int f()
{
double d = 0.0;
return d;
}
template<typename T>
int g()
{
double d = 0.0;
return d;
}
template<typename T>
T h()
{
double d = 0.0;
return d;
}
paolo:~/Work> more test.cc
#include "test.h"
int main()
{
f();
g<int>();
h<int>();
}
paolo:~/Work> g++ -c -Wconversion test.cc
test.h: In function 'int g() [with T = int]':
test.cc:6: instantiated from here
test.h:13: warning: converting to 'int' from 'double'
test.h:13: warning: conversion to 'int' from 'double' may alter its value
test.h: In function 'T h() [with T = int]':
test.cc:7: instantiated from here
test.h:20: warning: converting to 'int' from 'double'
test.h:20: warning: conversion to 'int' from 'double' may alter its value
--
Summary: pragma GCC system_header vs templates
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pcarlini at suse dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30500
More information about the Gcc-bugs
mailing list