[LLVMbugs] [Bug 23171] New: Improper function to pointer conversion in call expression in C++
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Apr 9 09:17:04 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23171
Bug ID: 23171
Summary: Improper function to pointer conversion in call
expression in C++
Product: clang
Version: 3.5
Hardware: Macintosh
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: alexandermbock at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150409/130cc61d/attachment.html>
More information about the llvm-bugs
mailing list