From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12935 invoked by alias); 12 Jun 2007 16:35:26 -0000 Received: (qmail 12925 invoked by uid 22791); 12 Jun 2007 16:35:25 -0000 X-Spam-Check-By: sourceware.org Received: from mail-in-13.arcor-online.net (HELO mail-in-13.arcor-online.net) (151.189.21.53) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 12 Jun 2007 16:35:20 +0000 Received: from mail-in-04-z2.arcor-online.net (mail-in-04-z2.arcor-online.net [151.189.8.16]) by mail-in-13.arcor-online.net (Postfix) with ESMTP id 953611E5A1E; Tue, 12 Jun 2007 18:35:17 +0200 (CEST) Received: from mail-in-02.arcor-online.net (mail-in-02.arcor-online.net [151.189.21.42]) by mail-in-04-z2.arcor-online.net (Postfix) with ESMTP id 5F8ABABF11; Tue, 12 Jun 2007 18:35:17 +0200 (CEST) Received: from [192.168.1.33] (dslb-084-056-161-117.pools.arcor-ip.net [84.56.161.117]) by mail-in-02.arcor-online.net (Postfix) with ESMTP id E2EDA36E871; Tue, 12 Jun 2007 18:35:11 +0200 (CEST) In-Reply-To: <466EC9C6.A5DF578A@dessent.net> References: <200706121826.34044.mihai.dontu@gmail.com> <466EC9C6.A5DF578A@dessent.net> Mime-Version: 1.0 (Apple Message framework v623) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Message-Id: Content-Transfer-Encoding: quoted-printable Cc: Mihai Don?u From: Segher Boessenkool Subject: Re: sizeof( function ) Date: Tue, 12 Jun 2007 16:56:00 -0000 To: gcc-help@gcc.gnu.org X-Mailer: Apple Mail (2.623) X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2007-06/txt/msg00151.txt.bz2 >> Not that is of great importance, but does anyone know why >> >> int main( void ) >> { >> return printf( "%d\n", ( int )sizeof( main ) ); >> } >> >> prints 1 ? :) > It is invalid to use sizeof() with a function > type expression (C99 =A76.5.3.4 para. 1) and hence this code invokes > undefined behavior. gcc gives a warning if you compile with -pedantic, > but otherwise it apparently just returns 1; See the description of -Wpointer-arith in the Fine Manual. Segher