[GCC-XML] wrong artificial op=()

Axel Naumann Axel.Naumann at cern.ch
Wed Oct 1 05:32:27 EDT 2008


Hi,

when running GCCXML 0.9 from 2008-09-09, built with gcc 3.4 for 64bit
GNU/Linux, on the following code:

struct S {
   public:
   S();
   const int _i;
};

int i;
struct T {
   public:
   T();
   int& _i;
};

struct U {
   private:
   U& operator=(const U&);
};

struct V: public U {};

struct W {
public:
   U _u;
};

with gccxml asgnop.h -fxml=asgnop.xml

the XML file contains an artificial operator=() for the classes S, T, V, and W.
This assignment operator should not exist according to the standard
[class.copy], 12.8.12. Both GCC 4.3 and MSVC 9.0 will refuse to compile code
that requires the implicit definition of these operators:

#include "asgnop.h"
void f() {
   S s; s = S();
   T t; t = T();
   V v; v = V();
   W w; w = W();
}

g++ -c asgnop.cxx
asgnop.h: In member function 'S& S::operator=(const S&)':
asgnop.h:1: error: non-static const member 'const int S::_i', can't use default
assignment operator
asgnop.cxx: In function 'void f()':
asgnop.cxx:3: note: synthesized method 'S& S::operator=(const S&)' first
required here
asgnop.h: In member function 'T& T::operator=(const T&)':
asgnop.h:8: error: non-static reference member 'int& T::_i', can't use default
assignment operator
asgnop.cxx: In function 'void f()':
asgnop.cxx:4: note: synthesized method 'T& T::operator=(const T&)' first
required here
asgnop.h: In member function 'V& V::operator=(const V&)':
asgnop.h:16: error: 'U& U::operator=(const U&)' is private
asgnop.h:19: error: within this context
asgnop.cxx: In function 'void f()':
asgnop.cxx:5: note: synthesized method 'V& V::operator=(const V&)' first
required here
asgnop.h: In member function 'W& W::operator=(const W&)':
asgnop.h:16: error: 'U& U::operator=(const U&)' is private
asgnop.h:21: error: within this context
asgnop.cxx: In function 'void f()':
asgnop.cxx:6: note: synthesized method 'W& W::operator=(const W&)' first
required here

Could these operators be suppressed, please?

Cheers, Axel.



More information about the gccxml mailing list