From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 563 invoked by alias); 30 Jan 2011 20:45:26 -0000 Received: (qmail 555 invoked by uid 22791); 30 Jan 2011 20:45:26 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,TW_CP,TW_OV,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from vm-emlprdomr-04.its.yale.edu (HELO vm-emlprdomr-04.its.yale.edu) (130.132.50.145) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 30 Jan 2011 20:45:20 +0000 Received: from [192.168.1.100] (cpe-69-200-237-227.nyc.res.rr.com [69.200.237.227]) (authenticated bits=0) by vm-emlprdomr-04.its.yale.edu (8.14.4/8.14.4) with ESMTP id p0UKjHFM001226 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Sun, 30 Jan 2011 15:45:18 -0500 From: Amittai Aviram Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: GCC Internals: built-in functions? Date: Sun, 30 Jan 2011 20:50:00 -0000 Message-Id: To: gcc-help@gcc.gnu.org Mime-Version: 1.0 (Apple Message framework v1082) 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: 2011-01/txt/msg00468.txt.bz2 On this GCC Internals page http://en.wikibooks.org/wiki/GNU_C_Compiler_Internals/GNU_C_Compiler_Archit= ecture_3_4 I found the following in the "GCC Initialization" section: "GCC built-in functions are the functions that are evaluated at compile tim= e. For example, if the size argument of a strcpy() function is a constant t= hen GCC replaces the function call with the required number of assignments." I was curious about this, so I tried compiling to assembly (-S) a very simp= le program: #include #include #include int main(void) { char s1[0x10]; char * s0 =3D "HELLO"; strcpy(s1, s0); printf("%s %s\n", s0, s1); return EXIT_SUCCESS; } But the resulting assembly code simply calls strcpy with the two arguments,= just as I would have expected had I not read the above sentence: movq $.LC0, -40(%rbp) movq -40(%rbp), %rdx leaq -32(%rbp), %rax movq %rdx, %rsi movq %rax, %rdi call strcpy (Here, .LC0 labels the string "HELLO".) So what does that sentence actually mean and what am I missing? Thanks! Amittai Aviram PhD Student in Computer Science Yale University 646 483 2639 amittai.aviram@yale.edu http://www.amittai.com