https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71285

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So is:

template <typename... Args>
int
foo (Args... args)
{
  return (... + args).member;
}

struct S { int member; } s = { 0 };

int
main ()
{
  return foo (s);
}

the complete testcase including instantiation that should be accepted?  clang++
3.9.1 rejects it too, with very different error.
On the gcc side, I think the problem is that with .member we have
UNARY_LEFT_FOLD_EXPR with LANG_TYPE type, and
cp_parser_postfix_dot_deref_expression uses
  dependent_p = type_dependent_object_expression_p (postfix_expression);
rather than type_dependent_expression_p (postfix_expression) to find out if it
is type-dependent or not.  If the testcase is:
template <typename... Args>
int
foo (Args... args)
{
  return (... + args)->member;
}

struct S { int member; } s = { 0 };

int
main ()
{
  return foo (&s);
}
then it works, because -> is handled by first creating ARROW_EXPR around the
fold expression, and ARROW_EXPR has NULL type, so
type_dependent_object_expression_p (postfix_expression); signals on it that it
is dependent.  Perhaps type_dependent_object_expression_p should return true
for fold expressions?

Reply via email to