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

            Bug ID: 111682
           Summary: valgrind error in tsubst_template_decl
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Recent gcc trunk, built with valgrind, when given this C++ source code
from the clang testsuite:

template<typename T> struct A {
  template<typename U> struct B;
  template<typename U> struct B<U*>;
};
template<typename T> template<typename U> struct A<T>::B<U*> {};
template struct A<int>;
A<int>::B<int*> b;


template<typename T> struct B {
  template<typename U> static const int var1;
  template<typename U> static const int var1<U*>;

  template<typename U> static const int var2;
};
template<typename T> template<typename U> const int B<T>::var1<U*> = 1;
template<typename T> template<typename U> const int B<T>::var2<U*> = 1;
template struct B<int>;
int b_test1[B<int>::var1<int*>];
int b_test2[B<int>::var2<int*>];


does this:

$ ~/gcc/results.20230927.valgrind/bin/gcc -c -w
./SemaTemplate/instantiate-partial-spec.cpp
==33844== Invalid read of size 2
==33844==    at 0x8CCA6B: tsubst_template_decl(tree_node*, tree_node*, int,
tree_node*, tree_node*) (pt.cc:14684)
==33844==    by 0x8B4469: tsubst_decl(tree_node*, tree_node*, int, bool)
(pt.cc:14933)
==33844==    by 0x8CE78B: most_specialized_partial_spec(tree_node*, int, bool)
(pt.cc:26255)

Reply via email to