The following, when compiled with  g++ -c myfile.cpp, produces only this
warning:
  myfile.cpp:4: warning: inline function 'A& A::operator=(const A&)' used but
  never defined
The surprises to me are (1) that this warning is even emitted, and (2) that if
the compiler emits this warning, it does not emit a warning about class A's
default ctor and copy ctor, which are also used but not defined.  The code:

#pragma interface

struct A
{
    virtual ~A();
};

template<typename T>
void f(const T& z)
{
    T x;
    T y(x);
    y = x;
}

int main()
{
    f(A());
}

I discovered the problem when recompiling some CGICC headers.  (This code is
simplified from those headers.)  There was no warning when compiling the
headers under g++ 3.2.3, but there was under g++ 4.0.1 and 4.0.2.

--David


-- 
           Summary: #pragma interface and warning about undefined
                    synthesized operator=
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: das at cs dot ucla dot edu
  GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24421

Reply via email to