https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90515

            Bug ID: 90515
           Summary: g++ ignores [[deprecated("text")]] in some template
                    specialisations
           Product: gcc
           Version: 9.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: p.cross13 at yahoo dot com
  Target Milestone: ---

#include <iostream>

// the deprecated attribute is ignored by the compiler for the BAD template. It
works for GOOD.

template <bool b> struct                         GOOD       {static constexpr 
int value=1012;};
template <>       struct [[deprecated("GOODT")]] GOOD<true> {static constexpr
int value=1099;};
template <>       struct                         GOOD<false>{static constexpr
int value=1000;};

template <bool b, long i> struct                        BAD          {static
constexpr int value=i;};
template <long i >        struct [[deprecated("BADT")]] BAD<true, i> {static
constexpr int value=100+i;};
template <long i >        struct                        BAD<false, i>{static
constexpr int value=-100+i;};


int main () {

        std::cout<<"GOODCLASS "<<GOOD<true>::value  <<':'<<GOOD<false>::value 
<<std::endl;

        GOOD<true>  goodt;
        GOOD<false> goodf;

        std::cout<<"GOODOBJECT "<<goodt.value<<':'<<goodf.value<<std::endl
<<std::endl;

        std::cout<<"BADCLASS "<< BAD<true,4>::value<<':'<<BAD <false,8>::value
<<std::endl;

        BAD<true,4>  badt4;
        BAD<false,8> badf8;

        std::cout<<"BADOBJECT "<<badt4.value <<':'<<badf8.value <<std::endl
<<std::endl;

        return 0;
}

/*

D:\>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=D:/mingw9.1MCF/bin/../lib/gcc/x86_64-w64-mingw32/9.1.1/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc/configure --prefix=/mingw64
--with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
--with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include
--libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64
--with-tune=nocona --enable-languages=c,lto,c++ --enable-shared --enable-static
--enable-threads=mcf --enable-graphite --enable-fully-dynamic-string
--enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug
--enable-libstdcxx-filesystem-ts=yes --disable-isl-version-check --enable-lto
--enable-libgomp --disable-multilib --enable-checking=release --disable-rpath
--disable-win32-registry --enable-nls --disable-werror --disable-symvers
--with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64
--with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='gcc-9-branch HEAD
with MCF thread model, built by LH_Mouse.'
--with-bugurl=https://gcc-mcf.lhmouse.com/ --with-gnu-as --with-gnu-ld
--disable-tls --enable-plugin
Thread model: mcf
gcc version 9.1.1 20190506 (gcc-9-branch HEAD with MCF thread model, built by
LH_Mouse.)

D:\>g++ -std=c++2a -Wall -Wextra deprecatedError.cpp
deprecatedError.cpp: In function 'int main()':
deprecatedError.cpp:18:14: warning: 'GOOD' is deprecated: GOODT
[-Wdeprecated-declarations]
   18 |  GOOD<true>  goodt;
      |              ^~~~~
deprecatedError.cpp:6:50: note: declared here
    6 | template <>       struct [[deprecated("GOODT")]] GOOD<true> {static
constexpr int value=1099;};
      |                                                  ^~~~~~~~~~

D:\>a
GOODCLASS 1099:1000
GOODOBJECT 1099:1000

BADCLASS 104:-92
BADOBJECT 104:-92


D:\>


Same result for 
$ g++ -v
Using built-in specs.
COLLECT_GCC=D:\msys64\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-8.3.0/configure --prefix=/mingw64
--with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32
--with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include
--libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64
--with-tune=generic --enable-languages=ada,c,lto,c++,objc,obj-c++,fortran
--enable-shared --enable-static --enable-libatomic --enable-threads=posix
--enable-graphite --enable-fully-dynamic-string
--enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes
--disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check
--enable-lto --enable-libgomp --disable-multilib --enable-checking=release
--disable-rpath --disable-win32-registry --disable-nls --disable-werror
--disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64
--with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64
--with-pkgversion='Rev2, Built by MSYS2 project'
--with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as
--with-gnu-ld
Thread model: posix
gcc version 8.3.0 (Rev2, Built by MSYS2 project)

peter@DESKTOP-U70S6AV MSYS /d
$

*/

Reply via email to