When an include dir is given to gcc with the -isystem option the warning: 'class CppUnit::ConcretTestFixtureFactory<ErrorValueTest>' has virtual functions but non-virtual destructor is not suppressed as other warnings are. This warning is new, with gcc34 or snapshot 20050116 this warning does not show up. Michael Cieslinski
I cannot reproduce this with 4.0 (20050222). tin:~/src/gnu/gcctest/pr20145>cat include/t.h class t { virtual void f(); }; tin:~/src/gnu/gcctest/pr20145>cat t.cc #include <t.h> class t1 { virtual void f(); }; void f(void) { t h; t1 h1; } tin:~/src/gnu/gcctest/pr20145>gcc t.cc -isystem include/ -W -Wall -S t.cc:4: warning: ‘class t1’ has virtual functions but non-virtual destructor
Oh, one more thing: tin:~/src/gnu/gcctest/pr20145>gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: /home/peshtigo/pinskia/src/gnu/gcc/src/configure --target=i686-pc-linux-gnu -- host=i686-pc-linux-gnu --enable-__cxa_atexit --enable-languages=c++,objc,java,f95 --prefix=/ home/gates/pinskia/linux --enable-threads=posix --enable-shared Thread model: posix gcc version 4.0.0 20050222 (experimental)
Can you include the preprocessed source (the preprocessed source will have the thing if a header is a system header or not)?
Created attachment 8261 [details] preprocessed source Command line for gcc: /usr/local/gcc40d/bin/g++40d -O2 -g -march=opteron -Wall -DALTIVEC -DUSEACE -c -o ../../../../LinuxExec/arrilib/ArriutilTest.o ../../../Portabel/arrilib/compile/ArriutilTest.cpp -I../../../Portabel/arrilib -isystem/home/cie019/ace542-gcc40/ACE_wrappers -DHAVE_ACE_NULL_MUTEX_H -isystem/usr/local/cppunit-gcc40/include -I../../../../include/arrilib Output from gcc: /usr/local/cppunit-gcc40/include/cppunit/extensions/TestFixtureFactory.h: In instantiation of 'CppUnit::ConcretTestFixtureFactory<ArriutilTest>': ../../../Portabel/arrilib/compile/ArriutilTest.h:32: instantiated from here /usr/local/cppunit-gcc40/include/cppunit/extensions/TestFixtureFactory.h:30: warning: 'class CppUnit::ConcretTestFixtureFactory<ArriutilTest>' has virtual functions but non-virtual destructor This gcc was snapshot 20050213, but 20050220 makes no difference. Michael Cieslinski
Ok, it is only a bug with templates. And here is the shortest testcase: # 1 "t.cc" # 1 "<built-in>" # 1 "<command line>" # 1 "t.cc" # 1 "include/t.h" 1 3 4 template <int> class t { virtual void f(); }; # 2 "t.cc" 2 void f(void) { t<1> h; }
I think this caused by the patch which fixed PR 19733.
The fact that something is in a system header does not in general cause the compiler not to warn about it. G++ does not issue certain pedantic warnings when in a system header, but this is not one of those.
(In reply to comment #7) > The fact that something is in a system header does not in general cause the > compiler not to warn about it. G++ does not issue certain pedantic warnings > when in a system header, but this is not one of those. Why does the non-template version does not warn then?
Andrew is correct. I missed the magic bit that disables warnings in system headers. (There are other pedwarns that we carefully guard with !in_system_header, but ordinary warnings are not so guarded.) I've reopened the bug.
Subject: Bug 20145 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: mmitchel@gcc.gnu.org 2005-04-08 19:36:12 Modified files: gcc/cp : ChangeLog cp-tree.def cp-tree.h tree.c pt.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/warn: Wdtor1.C Log message: * cp-tree.def (TINST_LEVEL): Document TINST_IN_SYSTEM_HEADER_P. * cp-tree.h (struct tinst_level): Add in_system_header_p. (TINST_IN_SYSTEM_HEADER_P): New macro. (make_tinst_level): Remove. * pt.c (lookup_template_class): Preserve DECL_IN_SYSTEM_HEADER on the instantiated class. (push_tinst_level): Do not use make_tinst_level. Set TINST_IN_SYSTEM_HEADER_P. (pop_tinst_level): Likewise. (instantiate_class_template): Set in_system_header. (instantiate_pending_templates): Likewise. * tree.c (make_tinst_level): Remove. PR c++/20145 * g++.dg/warn/Wdtor1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.29&r2=1.4648.2.30 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.94.4.1&r2=1.94.4.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1106.2.2&r2=1.1106.2.3 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.427.2.1&r2=1.427.2.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.978.2.6&r2=1.978.2.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.117&r2=1.5084.2.118 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wdtor1.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Subject: Bug 20145 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2005-04-08 19:39:59 Modified files: gcc/cp : ChangeLog cp-tree.def cp-tree.h tree.c pt.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/warn: Wdtor1.C Log message: * cp-tree.def (TINST_LEVEL): Document TINST_IN_SYSTEM_HEADER_P. * cp-tree.h (struct tinst_level): Add in_system_header_p. (TINST_IN_SYSTEM_HEADER_P): New macro. (make_tinst_level): Remove. * pt.c (lookup_template_class): Preserve DECL_IN_SYSTEM_HEADER on the instantiated class. (push_tinst_level): Do not use make_tinst_level. Set TINST_IN_SYSTEM_HEADER_P. (pop_tinst_level): Likewise. (instantiate_class_template): Set in_system_header. (instantiate_pending_templates): Likewise. * tree.c (make_tinst_level): Remove. PR c++/20145 * g++.dg/warn/Wdtor1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4694&r2=1.4695 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.def.diff?cvsroot=gcc&r1=1.95&r2=1.96 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.1116&r2=1.1117 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/tree.c.diff?cvsroot=gcc&r1=1.430&r2=1.431 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.991&r2=1.992 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5304&r2=1.5305 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wdtor1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
Fixed in 4.0.