[LLVMbugs] [Bug 16872] New: The sizeof operator shall not be applied directly to a function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Aug 13 04:37:38 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16872

            Bug ID: 16872
           Summary: The sizeof operator shall not be applied directly to a
                    function
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ruslan_baratov at yahoo.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

C++ 2003 standard forbid sizeof operator to function, 5.3.3, [expr.sizeof]:
> 3. The sizeof operator can be applied to a pointer to a function, but shall not be applied directly to a function.
> 4. The lvalue-to-rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are not applied to the operand of sizeof.

This simple example:
void func() {
}

int main() {
  return sizeof(func);
}

produce error C2070: 'void (void)': illegal sizeof operand with MSVC 2012
compiler,
g++ (4.7.3) give error: ISO C++ forbids applying 'sizeof' to an expression of
function type
but no error from clang

-- 
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/20130813/5232a5cd/attachment.html>


More information about the llvm-bugs mailing list