Bug 95302 - function attributed to be deprecated cannot include a typedef/using
Summary: function attributed to be deprecated cannot include a typedef/using
Status: RESOLVED DUPLICATE of bug 99318
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2020-05-24 10:19 UTC by URABE, Shyouhei
Modified: 2021-08-12 00:38 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 10.3.0, 11.1.0
Known to fail: 10.2.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description URABE, Shyouhei 2020-05-24 10:19:31 UTC
https://gcc.godbolt.org/z/iH643m

Is this intentional? No other compiler that I know warns this code.

% cat tmp.cc
[[deprecated(">>>GCC BUG<<<")]]
void func(void)
{
    typedef int type;
    type(var);
}
% g++-10 -v -c tmp.cc
Using built-in specs.
COLLECT_GCC=g++-10
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.1.0-2ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-eDoCEC/gcc-10-10.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-eDoCEC/gcc-10-10.1.0/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.1.0 (Ubuntu 10.1.0-2ubuntu1~18.04)
COLLECT_GCC_OPTIONS='-v' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/10/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE tmp.cc -quiet -dumpbase tmp.cc -mtune=generic -march=x86-64 -auxbase tmp -version -fasynchronous-unwind-tables -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccz4O9iB.s
GNU C++14 (Ubuntu 10.1.0-2ubuntu1~18.04) version 10.1.0 (x86_64-linux-gnu)
        compiled by GNU C version 10.1.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/10"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/include-fixed"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/10
 /usr/include/x86_64-linux-gnu/c++/10
 /usr/include/c++/10/backward
 /usr/lib/gcc/x86_64-linux-gnu/10/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++14 (Ubuntu 10.1.0-2ubuntu1~18.04) version 10.1.0 (x86_64-linux-gnu)
        compiled by GNU C version 10.1.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 435c9a72f92ce04eba08a47828fa63c4
tmp.cc: In function 'void func()':
tmp.cc:5:13: warning: 'void func()' is deprecated: >>>GCC BUG<<< [-Wdeprecated-declarations]
    5 |     type(var);
      |             ^
tmp.cc:2:6: note: declared here
    2 | void func(void)
      |      ^~~~
COLLECT_GCC_OPTIONS='-v' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 as -v --64 -o tmp.o /tmp/ccz4O9iB.s
GNU assembler version 2.30 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.30
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-c' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
Comment 1 Anatol 2020-06-06 15:42:55 UTC
Shyouhei, thank you for filing this ticket.

I agree that GCC should not complain about deprecated usage if the symbol is not really used.

Such GCC behavior causes excessive compile time warnings when using SWIG library https://github.com/swig/swig/issues/1689#issuecomment-636109918
Comment 2 Rafael Avila de Espindola 2020-06-29 19:37:00 UTC
The same problem happens with a namespace alias:

namespace foo {
void bar();
}
[[deprecated("zed")]] inline void zed() {
    namespace a = foo;
    a::bar();
}

Produces:

test.cc: In function ‘void zed()’:
test.cc:6:8: warning: ‘void zed()’ is deprecated: zed [-Wdeprecated-declarations]
    6 |     a::bar();
      |        ^~~
test.cc:4:35: note: declared here
    4 | [[deprecated("zed")]] inline void zed() {
      |                                   ^~~


If instead of the alias foo::bar() is used directly, no warning is produced.

The issue is still present on current master (346bce6fe0cf1ed5f6a7ad732d2361d77b203c87).
Comment 3 Andrew Pinski 2021-08-11 20:56:18 UTC
Seems fixed in GCC 10.3.0 and 11+.
Comment 4 Andrew Pinski 2021-08-11 20:57:37 UTC
Dup of bug 99318.

*** This bug has been marked as a duplicate of bug 99318 ***
Comment 5 URABE, Shyouhei 2021-08-12 00:38:31 UTC
Confirmed fixed at GCC 10.3.0.  Thank you!