From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21148 invoked by alias); 27 Feb 2009 21:07:37 -0000 Received: (qmail 21140 invoked by uid 22791); 27 Feb 2009 21:07:36 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_FAIL X-Spam-Check-By: sourceware.org Received: from mx20.gnu.org (HELO mx20.gnu.org) (199.232.41.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Feb 2009 21:07:32 +0000 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ld9vc-0006PZ-UP for gcc@gcc.gnu.org; Fri, 27 Feb 2009 16:07:29 -0500 Received: (qmail 8982 invoked from network); 27 Feb 2009 21:07:28 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 27 Feb 2009 21:07:28 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.69) (envelope-from ) id 1Ld9va-00016O-UG; Fri, 27 Feb 2009 21:07:26 +0000 Date: Fri, 27 Feb 2009 21:07:00 -0000 From: "Joseph S. Myers" To: Sean D'Epagnier cc: gcc@gcc.gnu.org, fu@mips.com Subject: Re: type promotion for fixed point types In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-02/txt/msg00494.txt.bz2 On Fri, 27 Feb 2009, Sean D'Epagnier wrote: > Hi, > > I just added support for printf and scanf of fixed point types to avr > libc. I wanted to handle: > > Currently "accum" and "fract" work, but not "short accum" or "short fract" > > This is not a problem for integers currently since they get type > promoted when passed with stdarg. > > There is nothing in the fixed-point standard that is for or against > this.. it seems logical that "short accum" be promoted to "accum" and > "short fract" be promoted to "fract" in this case. > > Does anyone have any opinions on this? The promotion of "float" to "double" when passed to a variadic function is considered a legacy anomaly. Thus, the default argument promotions (applied to variable arguments) should be considered to be the "integer promotions", float to double, and nothing else. (In particular, it is deliberate that float _Complex does not promote to double _Complex - see DR#206 - and likewise float _Imaginary (not supported by GCC) does not promote to double _Imaginary.) Unless your promotion is defined as being one of the "integer promotions", it should thus not occur. Your printf implementation should call va_arg with the correct unpromoted type when it is passed an appropriate one of the fixed-point printf formats defined in the fixed-point TR. -- Joseph S. Myers joseph@codesourcery.com