Title
Is a comma-expression dependent if its first operand is?
Status
nad
Section
13.8.3.3 [temp.dep.expr]
Submitter
John Spicer

Created on 2002-01-10.00:00:00 last changed 244 months ago

Messages

Date: 2004-10-15.00:00:00

Rationale (October, 2004):

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

Date: 2022-11-20.07:54:16

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?

History
Date User Action Args
2004-11-07 00:00:00adminsetmessages: + msg1107
2004-11-07 00:00:00adminsetstatus: open -> nad
2002-01-10 00:00:00admincreate