https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65974
Bug ID: 65974 Summary: Bogus deprecated-declarations warnings for inline definitions of deprecated virtual methods Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vz-gcc at zeitlins dot org Target Milestone: --- Consider the following example: % cat -n deprdecl.cpp 1 struct S { 2 void bar(); 3 4 __attribute__((deprecated("use bar() instead."))) 5 virtual void foo(); 6 }; 7 8 inline void S::foo() { bar(); } 9 10 int main() 11 { 12 return 0; 13 } % g++-5 -c -Wall deprdecl.cpp deprdecl.cpp:13:1: warning: 'virtual void S::foo()' is deprecated: use bar() instead. [-Wdeprecated-declarations] } ^ deprdecl.cpp:8:13: note: declared here inline void S::foo() { bar(); } ^ I believe this warning shouldn't appear when the deprecated method is just being defined and not used. Notice that it indeed does not appear if the method is either not virtual (i.e. remove "virtual" in line 5) or is defined inline (i.e. move the body from line 8 to line 5). Nor does it appear with 4.9. Also notice that the warning location is always the last line of the last function in the file and has nothing to do with the function it complains about. This warning may look like not a big deal, but when compiling my real code it occurs many thousands times making it impossible to use deprecated attribute with g++ 5.1. Compiler information: % g++-5 -v Using built-in specs. COLLECT_GCC=g++-5 COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 5.1.1-2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=c++11 --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 5.1.1 (Debian 5.1.1-2)