Hi all,

Caolan recently brought to our attention that GCC 4 will probably be quite picky about certain C++ constructs, more so than any other known compiler, and probably beyond practicability.

The problem is that certain types (14.3.1/2: "A local type, a type with no linkage, an unnamed type or a type compounded from any of these [...]") cannot be used as template arguments, yet overload resolution sometimes tries to instantiate function templates with such types and fails. It is open how a compiler should behave in such a case (see <http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#488>), and GCC 4, as it currently seems, prefers to be rather picky for now.

The problem hits the OOo code base in cases like

  enum { BIT_MASK = 0x123 };
  int i = ...;
  if (i == BIT_MASK) ...

when for example com/sun/star/uno/Any.hxx has been included, which declares a

  template< typename T > bool operator ==(Any const & x1, T const & x2)

and trying to resolve the use of the overloaded operator == above, the compiler will consider this function template, which leads to an error, as T would have to be bound to an unnamed enum type.

The morale? Well, I am not sure. Stop using C++, as it is not a language you want to mess around with; bite the bullet and avoid unnamed and local enums; maybe it would also have been more clever to hide the Any's operator == template function in namespace com::sun::star::uno...

-Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to