<html>
    <head>
      <base href="https://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 --- - Improper function to pointer conversion in call expression in C++"
   href="https://llvm.org/bugs/show_bug.cgi?id=23171">23171</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Improper function to pointer conversion in call expression in C++
          </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>Given this code:

    void f() {
        f();
    }

clang generates this AST:

TranslationUnitDecl 0x1028254d0 <<invalid sloc>>
|-TypedefDecl 0x102825a10 <<invalid sloc>> __int128_t '__int128'
|-TypedefDecl 0x102825a70 <<invalid sloc>> __uint128_t 'unsigned __int128'
|-TypedefDecl 0x102825e30 <<invalid sloc>> __builtin_va_list '__va_list_tag
[1]'
`-FunctionDecl 0x102825ed0 <bgt.cpp:1:1, line:3:1> f 'void (void)'
  `-CompoundStmt 0x102826058 <line:1:10, line:3:1>
    `-CallExpr 0x102826030 <line:2:5, col:7> 'void'
      `-ImplicitCastExpr 0x102826018 <col:5> 'void (*)(void)'
<FunctionToPointerDecay>
        `-DeclRefExpr 0x102825fc8 <col:5> 'void (void)' lvalue Function
0x102825ed0 'f' 'void (void)'

Note the ImplicitCastExpr <FunctionToPointerDecay>.

[expr.call]/1 says:
For a call to a non-member function or to a static member function, the postfix
expression shall be either an lvalue that refers to a function (in which case
the function-to-pointer standard conversion is suppressed on the postfix
expression), or it shall have pointer to function type.

I would not expect the AST to contain a function to pointer conversion when the
standard explicitly states that one does not occur. I am not aware of any
circumstance in which this could change the observable behavior of a program,
but it complicates tool development when the AST does not match what is
expected from the standard.

Note that this does not apply to C; C11 6.5.2.2 says:
The expression that denotes the called function shall have type pointer to
function returning void or returning a complete object type other than an array
type.</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>