[cfe-dev] unhelpful error message for missing typename

Luc Bourhis luc_j_bourhis at mac.com
Sat Oct 23 10:31:08 PDT 2010


Consider the following code (a reduction of some actual code of mine):

------------------------------------------------------------------------------------------------------
struct site_symmetry_ops { };

template <class wt>
struct class_
{
  template <class A1>
  void def(A1 const &a1) {}
};

template <class A1, class A2>
struct init
{
  init() { }
};

struct special_position_site_parameter { 
  typedef char scatterer_type;
};

template <class wt>
struct valued_asu_parameter_heir_wrapper
{
  static class_<wt> wrap(char const *name) {
    return class_<wt>();
  }
};

template <class wt>
struct special_position_wrapper
{
  static void wrap(char const *name) {
    valued_asu_parameter_heir_wrapper<wt>::wrap(name)
      .def(init<site_symmetry_ops const &, wt::scatterer_type *>())
      ;
  }
};

void wrap_special_position() {
  special_position_wrapper<special_position_site_parameter>
  ::wrap("special_position_site_parameter");
}
------------------------------------------------------------------------------------------------------

clang++ (trunk 116866) generates the following error message:

test.cpp:29:64: error: expected expression
      .def(init<site_symmetry_ops const &, wt::scatterer_type *>())
                                                               ^
1 error generated.

The problem is of course that a 'typename' is missing in front of 'wt::scatterer_type'. The error message does not suggest that, not even implicitly. This is the only case I know of where g++ error message is more informative than clang++ actually!!

Cheers,

Luc Bourhis




More information about the cfe-dev mailing list