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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|wrong-code                  |link-failure

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Testcase from PR 82297, which produces an undefined reference for a function
used in a default argument of an inherited constructor:

template<class T>
struct bug_t {};

template<class T>
bug_t<T> make_bug(const T&) { return {}; }

template<class T>
struct Test {
  template<class U>
  Test(const U& , const bug_t<U> = make_bug(0)) {}

  /**
   * Also generates an error, at compile time, related bug ?
   */
  // template<class U>
  // Test(const U& , const bug_t<U> = make_bug<U>(0)) {}
};

template<class T>
struct img_t : Test<T> {
  using Test<T>::Test;
};

template<class T = char>
img_t<T> make_img(int val) {
  return {val};
}

int main() {
  make_img(2);
}

/tmp/ccix9VDk.o: In function `img_t<char> make_img<char>(int)':
inh.cc:(.text._Z8make_imgIcE5img_tIT_Ei[_Z8make_imgIcE5img_tIT_Ei]+0x1e):
undefined reference to `bug_t<int> make_bug<int>(int const&)'
collect2: error: ld returned 1 exit status

Reply via email to