$ cat junk.cc template <typename T> struct List { struct D { int size; }; D *d;
List &fill(const T &t, int size = -1); }; template <typename T> List<T> &List<T>::fill(const T &t, int size) { resize(size ? 1 : d->size); return *this; } $ /usr/local/gcc-4.1-20051001/bin/g++ -c junk.cc # silently accepted Replacing "resize(size...);" with "resize(1);" correctly rejects the bogus source (g++ versions 3.4 and above): junk.cc: In member function 'List<T>& List<T>::fill(const T&, int)': junk.cc:13: error: there are no arguments to 'resize' that depend on a template parameter, so a declaration of 'resize' must be available junk.cc:13: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) -- Summary: [accept invalid] Invalid template code accepted Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ppluzhnikov at charter dot net GCC build triplet: x86_64-redhat-linux GCC host triplet: x86_64-redhat-linux GCC target triplet: x86_64-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24680