This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


334. Is a comma-expression dependent if its first operand is?

Section: 13.8.3.3  [temp.dep.expr]     Status: NAD     Submitter: John Spicer     Date: 10 Jan 2002

Is the comma expression in the following dependent?

  template <class T> static void f(T)
  {
  }
  template <class T> void g(T)
  {
    f((T::x, 0));
  }
  struct A {
    static int x;
  };
  void h()
  {
    g(A());
  }

According to the standard, it is, because 13.8.3.3 [temp.dep.expr] says that an expression is dependent if any of its sub-expressions is dependent, but there is a question about whether the language should say something different. The type and value of the expression are not really dependent, and similar cases (like casting T::x to int) are not dependent.

Mark Mitchell: If the first operand is dependent, how do we know it does not have an overloaded comma operator?

Rationale (October, 2004):

CWG agreed that such comma expressions are and ought to be dependent, for the reason expressed in Mark Mitchell's comment.