C++ bug 764

Gabriel Dos Reis gdr@codesourcery.com
Mon May 7 04:28:00 GMT 2001


Nathan Sidwell <nathan@codesourcery.com> writes:

| Hi,
| In reexamining bug 764, I'm not convinced the code is well-formed.

Well, I think the code (the example you posted below) is well-formed
and the compiler is behaving in a non-conformant way.

| (Martin, we may have corresponded on this, but I cannot find any of
| that email).
| 
| The code in question is this [note, that this is in a follow up, as the
| original bug report code wasn't what martin intended]
| 
| template <class T>
|  struct S
|  {
|      friend bool operator== (const S&, const S&) {
|          return true;
|      }
|  };
|  
|  int main ()
|  {
|      // S<int> s;
|  
|      const S<int> *p = 0;

Right now, just instantiating the name declaration S<int> is sufficient.

|      *p == *p; // error

At this point, we need to instantiate the class S<int> in order to
form the overload set.  See 13.3.1.2/3.

|  }
|  
| g++ says,
| 
| test.cpp: In function `int main()':
| test.cpp:33: no match for `const S<int> & == const S<int> &'

This is boggus.

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com



More information about the Gcc-bugs mailing list