19980824 bug in 3 user-defined operators
Alexandre Oliva
oliva@dcc.unicamp.br
Wed Sep 2 21:02:00 GMT 1998
Reid M Pinchback <reidmp@MIT.EDU> writes:
> ** egcs is doing promotion for three user-defined unary
> ** operators (~,-,+)
Nope, it is doing integral promotion of integral types, as required in
[expr.unary.op]/6,7,9. The expression `+((short)1)', for example, has
type `int', not `short'.
> template <> class X<short> { template <class From> X(const From& v);
> public: typedef short type; inline X operator+() { return +val; }
> private: type val; };
In spite of `val' having type `short', `+val' has type `int', but the
constructor `X<short>::<int>X(int const&)' is not defined, so you get
a linker error.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
More information about the Gcc-bugs
mailing list