Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Because the C(99) standard requires (&sect;6.5.3.4/1)</p> <blockquote> <p><strong>The <code>sizeof</code> operator shall not be applied to an expression that has function type</strong> or an incomplete type, to the parenthesized name of such a type, or to an expression that designates a bit-field member. </p> </blockquote> <p>so the return value is meaningless. If you need the <code>sizeof</code> the function pointer, use </p> <pre><code>sizeof(&amp;main) sizeof(&amp;printf) sizeof(&amp;scanf) </code></pre> <hr> <p>gcc returns 1 on types that the sizeof is meaningless (see <a href="http://gcc.gnu.org/viewcvs/trunk/gcc/c-family/c-common.c?revision=164754&amp;view=markup" rel="noreferrer">c-common.c</a>):</p> <pre><code>4187 if (type_code == FUNCTION_TYPE) 4188 { 4189 if (is_sizeof) 4190 { 4191 if (complain &amp;&amp; (pedantic || warn_pointer_arith)) 4192 pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, 4193 "invalid application of %&lt;sizeof%&gt; to a function type"); 4194 else if (!complain) 4195 return error_mark_node; 4196 value = size_one_node; 4197 } 4198 else 4199 value = size_int (FUNCTION_BOUNDARY / BITS_PER_UNIT); 4200 } 4201 else if (type_code == VOID_TYPE || type_code == ERROR_MARK) 4202 { 4203 if (type_code == VOID_TYPE 4204 &amp;&amp; complain &amp;&amp; (pedantic || warn_pointer_arith)) 4205 pedwarn (loc, pedantic ? OPT_pedantic : OPT_Wpointer_arith, 4206 "invalid application of %qs to a void type", op_name); 4207 else if (!complain) 4208 return error_mark_node; 4209 value = size_one_node; 4210 } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload