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

            Bug ID: 98523
           Summary: Bug with class static definition and non-type template
                    parameters
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eldlistmailingz at tropicsoft dot com
  Target Milestone: ---

The code, as test_predicate.cpp:

template < typename T, T *d >  class atmp { atmp() {} };

template < typename T > struct ast
    {
    static T avar;
    static atmp<T,&avar> acst;
    };

template < typename T > T ast<T>::avar;
template < typename T > atmp<T,&ast<T>::avar> ast<T>::acst;

int main() 
    {
    return 0;
    }

The command line:

"/usr/bin/g++"   -fvisibility-inlines-hidden -fPIC -m64 -pthread -O0
-fno-inline -Wall -g -fvisibility=hidden -std=c++11 -c -o "test_predicate.o"
"test_predicate.cpp"

The result:

test_predicate.cpp:10:47: error: conflicting declaration ‘atmp<T, (&
ast<T>::avar)> ast<T>::acst’
   10 | template < typename T > atmp<T,&ast<T>::avar> ast<T>::acst;
      |                                               ^~~~~~
test_predicate.cpp:6:26: note: previous declaration as ‘atmp<T, (&
ast<T>::avar)> ast<T>::acst’
    6 |     static atmp<T,&avar> acst;
      |                          ^~~~

The code compiles successfully with clang-11.0 and with VC++ 14.2 on Windows.

Reply via email to