From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44254 invoked by alias); 13 Jun 2018 20:55:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 42856 invoked by uid 89); 13 Jun 2018 20:55:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Another X-HELO: mail-ot0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=5DM3qLEYSsZUy9uJS0fPlV9MZYVejYsENkAiwRe5cVs=; b=P1WHGhtOPcppEex3ZsTGxBMl8jvxH/0Y+hGUcX5po4GAmoQSEmmXtzBv+C1NzG/r3p BYSpf5cNGuBoo/Bfv8AN8/BJpYqJhYT0cxGDJOM8FZT/VKsYid5MJmAtD9s8Ce3U7biT 6GjAbvJ/ALVhcFzrP2Yso7n3MZPqmhwgyN/NJ8v93HLdsnuvGZiYFrZDbg3ajYby+Eo1 mMOIV0L2de4APeMEogBb2ipMWVwe03HU49fdI8DrZPIZIhH1BE2yoFqGCjOLmOUSK1Ax GNDGgrZsgoydHIP3ht5Sw4V74LP1EbJzuI3KJo70GmUbdfePHxPL+Rc/40VmX+Bzi0R0 9MkA== X-Gm-Message-State: APt69E3k+sahjcxtFMQuOy6ZriNIn18+Ls4Lv/btg6Ul4XVvXkY0vHXz JtPzLFUR0367t0v9dWTXRcrTOw== X-Google-Smtp-Source: ADUXVKKP8xqAnVmJT/TFsoVXWtugdoo7lGsVRmyZYNHi0nFOOZJga8tIsEg4eWVUpyOMUqVEj9PApg== X-Received: by 2002:a9d:705d:: with SMTP id x29-v6mr4210373otj.308.1528923321644; Wed, 13 Jun 2018 13:55:21 -0700 (PDT) Subject: Re: [PATCH] mention disabling GCC built-ins for customization To: Florian Weimer References: <2f2f96d3-5487-f791-8554-310beae0721b@gmail.com> <87vaam1l28.fsf@mid.deneb.enyo.de> Cc: GNU C Library From: Martin Sebor Message-ID: <69516fec-ef30-232a-cb4b-a1cc6d32e577@gmail.com> Date: Wed, 13 Jun 2018 20:55:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <87vaam1l28.fsf@mid.deneb.enyo.de> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2018-06/txt/msg00362.txt.bz2 On 06/13/2018 02:35 PM, Florian Weimer wrote: > * Martin Sebor: > >> @strong{Portability Note:} The ability to extend the syntax of >> @code{printf} template strings is a GNU extension. ISO standard C has >> -nothing similar. >> +nothing similar. When using the GNU C compiler or any other compiler >> +that interprets calls to standard I/O functions according to the rules >> +of the language standard it is necessary to disable such handling by >> +the appropriate compiler option. Otherwise the behavior of a program >> +that relies on the extension is undefined. > > Aren't there ISO extensions to C which define additional format > specifiers which GCC knows nothing about? So maybe it makes more > sense to say that if the application uses format specifiers not known > by GCC, behavior is undefined (unless the compiler option is used). The GCC optimization is disabled when the format string contains invalid or unhandled specifiers/modifiers etc, so even those may still be undefined in Glibc they aren't a problem for GCC. What would cause a problem for the GCC optimization is a change to the behavior of one of the standard conversions, like %i, or %s. One example would be changing the number of bytes output by the conversion. Another example of a future GCC optimization that would lead to undefined behavior is a hook that modified the string argument to %s (when GCC starts to assume that the argument is not clobbered by a sprintf call). Martin