<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Inconsistent rules for parenthesizing bound functions"
   href="http://llvm.org/bugs/show_bug.cgi?id=22668">22668</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inconsistent rules for parenthesizing bound functions
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.5
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alexandermbock@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Neither [expr.pseudo] (Example 1) nor [expr.mptr.oper] (Example 2) explicitly
states whether or not enclosing their "bound callable" expressions in
parentheses is acceptable (though [expr.mptr.oper] contains a (non-normative)
example of calling a pointer to member function using parentheses). Despite
almost identical wording for the requirement that .*/->*/.~ be used to perform
a call, clang requires parentheses for pointer to member function calls but
does not allow them for pseudo destructor calls.

Additionally, I'm not clear from the wording of the standard if an uncalled
bound function is permitted as the expression of an expression statement
(mainly because I see no wording that allows parentheses explicitly, so
presumably this is also a valid expression in other places where it is not
"used" -- this depends heavily on how one interprets "can be used in exactly
the same contexts", which I would intuitively take as waiver of the
requirements a context imposes on its operand, but not vice versa).

>From [expr.pseudo]:
"The use of a pseudo-destructor-name after a dot . or arrow -> operator
represents the destructor for the non-class type denoted by type-name or
decltype-specifier. The result shall only be used as the operand for the
function call operator (), and the result of such a call has type void."

>From [expr.mptr.oper]:
"If the result of .* or ->* is a function, then that result can be used only as
the operand for the function call operator ()."

>From [expr.prim.general]:
"A parenthesized expression is a primary expression whose type and value are
identical to those of the enclosed expression. The presence of parentheses does
not affect whether the expression is an lvalue. The parenthesized expression
can be used in exactly the same contexts as those where the enclosed expression
can be used, and with the same meaning, except as otherwise indicated."

Example 1:

typedef int I;

void f(int i) {
    i.~I(); // accepted
    (i.~I)(); // error: pseudo-destructor expression
              // must be called immediately with '()'
}

==
Example 2:
==

struct X;

void f(X& x) {
    void (X::*p)();
    // x.*p(); // this isn't an option due to the precedence rules
    (x.*p)(); // accepted, even though the similar case in the pseudo
destructor example is not

    x.*p; // error: reference to non-static member function must be called;
          // did you mean to call it with no arguments?
}



Given that gcc and edg both consider the use as an expression statement illegal
but allow extra parentheses around a pseudo destructor expression, I think the
most reasonable resolution is probably to allow (i.~I)().</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>