Question related to changes in template handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
was the handling of templates changed for g++12? I've run across some programs
which did compile with e.g. g++8, g++11, but no longer compile with g++12.
The fix is quite easy, but I wonder if this change is a bug, or a more strict
implementation of the standard.
Here is a short example program:================================================// compiles with g++ 11, not g++ 12
#include <vector>namespace NN   // if namespace is removed (i.e. global namespace is used), problem does not occur{  class OStr {};}
template <class T> NN::OStr& operator<<(NN::OStr& lhs, const std::vector<T>& rhs) { return lhs << rhs[0]; }
// moving this definition before the other template definition fixes gcc 12 compile problemtemplate <class T> NN::OStr& operator<< (NN::OStr& lhs, const T& rhs) { return lhs << rhs; }
int main(){   std::vector<int> a;   NN::OStr os;   os << a;   return 0;}=================================================
Regards
Klaus




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux