This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/40595] [C++0x] ICE trying to use sfinae with variadic template pack expansion



------- Comment #3 from jwakely dot gcc at gmail dot com  2009-06-30 10:52 -------
The basic problem is I've made std::result_of too good ;-)

My new result_of uses decltype to determine the exact result type of an
arbitrary function call, including resolving overloads based on whether the
callable object and arguments are lvalues or rvalues.

If you look at struct _Bind in include/tr1_impl/functional you will see it has
multiple overloads of operator() and __call() with different cv-qualifiers.
Those overloads are used to ensure the cv qualifiers of the functor _M_f are
the same as the cv qualifiers of the _Bind object, as required by
[func.bind.bind].  The return type of those overloads uses result_of, but that
involves forming invalid expressions e.g. when there is no const volatile
operator() on the functor type.

I can solve that by using sfinae to remove the overloads when the expression is
invalid, but this bug prevents it.

A temporary solution would be to remove the const and volatile overloads for
now.  That will work for 99% of cases, and will pass most of the testsuite,
because users don't usually invoke const or volatile binders.

This would fail under that workaround:

void f(int);
auto const b = std::bind(f, 1);
b();

Another options would be to support the example above, but to fudge the
result_of so that it does not use the correct cv qualifiers.  That would fail
for this case:

struct F {
  char* operator() const;
  int operator();
};

i.e. when the cv qualifiers of the function object are significant and affect
the result type of the function call operator. For that type, using result_of
with the wrong cv qualifiers would cause _Bind to fail, because it infers a
result tyep that is not convertible to the actual result of the call.


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]