Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does sizeof(function) makes sense?

I am a bit confused about the sizeof(function). I used to think that sizeof operator operates on class objects, pointers, and references.

What operands can the sizeof operator operate?

Does sizeof(function) make sense?

like image 962
Aniket Khedekar Avatar asked Dec 18 '22 22:12

Aniket Khedekar


1 Answers

As per: http://en.cppreference.com/w/cpp/language/sizeof

"...sizeof cannot be used with function types, incomplete types, or bit-field glvalues"

or from the 2012 Working Draft of the C++ Standard at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf:

Section 5.3.3 Sizeof "The sizeof operator shall not be applied to an expression that has function or incomplete type, to an enumeration type whose underlying type is not fixed before all its enumerators have been declared, to the parenthesized name of such types, or to an lvalue that designates a bit-field."

like image 176
Avi Weiss Avatar answered Jan 10 '23 20:01

Avi Weiss