From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11753 invoked by alias); 9 Oct 2012 07:18:45 -0000 Received: (qmail 11741 invoked by uid 22791); 9 Oct 2012 07:18:43 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO X-Spam-Check-By: sourceware.org Received: from saarni.dnainternet.net (HELO saarni.dnainternet.net) (83.102.40.136) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Oct 2012 07:18:36 +0000 Received: from localhost (localhost [127.0.0.1]) by saarni.dnainternet.net (Postfix) with ESMTP id CAC8C6091F; Tue, 9 Oct 2012 10:18:34 +0300 (EEST) X-Spam-Score: -1 Received: from saarni.dnainternet.net ([83.102.40.136]) by localhost (saarni.dnainternet.net [127.0.0.1]) (DNA Postiturva, port 10041) with ESMTP id rAct+cQwMLp7; Tue, 9 Oct 2012 10:18:34 +0300 (EEST) Received: from kirsikkapuu.dnainternet.net (kirsikkapuu.dnainternet.net [83.102.40.214]) by saarni.dnainternet.net (Postfix) with ESMTP id EEDD160AE7; Tue, 9 Oct 2012 10:17:58 +0300 (EEST) Received: from Niukka.Niemitalo.private (85-131-104-149.bb.dnainternet.fi [85.131.104.149]) by kirsikkapuu.dnainternet.net (Postfix) with ESMTP id A39502BAF4; Tue, 9 Oct 2012 10:17:56 +0300 (EEST) From: Kalle Olavi Niemitalo To: naveen yadav Cc: gcc-help@gcc.gnu.org Subject: Re: fprintf control from Environment variable. Keywords: fprintf,builtin,inline,Wformat In-Reply-To: (naveen yadav's message of "Tue, 9 Oct 2012 10:52:47 +0530") References: User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.51 (gnu/linux) Date: Tue, 09 Oct 2012 07:18:00 -0000 Message-ID: <87zk3w5d0k.fsf@Niukka.kon.iki.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: 2012-10/txt/msg00054.txt.bz2 naveen yadav writes: > I checked that for fprintf() call if stream is other then stdout or > stderr then code flows comes to vfprintf() function and if stream is > stdout or stderr then code flow is different and fwrite() function is > getting called. Use gcc -fno-builtin-fprintf to disable this transformation. However, that option also makes GCC not warn about calls like fprintf(stdout, "hahaha%s\n") where the format string does not match the argument list. You can restore those warnings by declaring fprintf with __attribute__((format(printf, 2, 3))). of glibc apparently does not do that. According to gcc/builtins.c (avoid_folding_inline_builtin), another way to disable the transformation would be to declare fprintf as an inline __attribute__((always_inline)) function. However, that causes an error if compiling with gcc -O2. If you only declare fprintf without a function body: In file included from test-builtin-fprintf.c:1:0: /usr/include/stdio.h:353:12: error: inlining failed in call to always_inl= ine =E2=80=98fprintf=E2=80=99: function body not available test-builtin-fprintf.c:24:10: error: called from here If you define fprintf with a function body: In file included from test-builtin-fprintf.c:1:0: test-builtin-fprintf.c: In function =E2=80=98fprintf=E2=80=99: /usr/include/stdio.h:353:12: error: function =E2=80=98fprintf=E2=80=99 ca= n never be inlined because it uses variable argument lists