From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=98.137.64.217; helo=sonic303-36.consmr.mail.gq1.yahoo.com; envelope-from=zenith432@users.sourceforge.net; receiver=edk2-devel@lists.01.org Received: from sonic303-36.consmr.mail.gq1.yahoo.com (sonic303-36.consmr.mail.gq1.yahoo.com [98.137.64.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A6C2D20356262 for ; Sun, 10 Dec 2017 06:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1512916876; bh=WcUfch8BOMuhRqMwN1ggkK7VcrKu4bD6yfj+K44DMq4=; h=Subject:To:References:From:Date:In-Reply-To:From:Subject; b=dF4jR2JrQc0+Wx3Yecbr9Z+0KrHtRk1fMPklqOJlzizKc49jyESfsnGcM2Dlsw7AKblgtD3d6ct1B6+aTXCebcEbRN5pVEJE0z31U/BwhB/AeYbYsej6sY7uY894PFvNuvbZOZLBau2x/n/HI1F1kSfj8LaC6ef/OrsYca3Z2MtvP3tZcHOcTnp8RMr+ksmG4P77ioeY97LwuW+a8c5jEkt1Oj1p0ISGWWvCblobhEAo7uKtn18lC9oaBSifu8Z//nYYd23tWV4WA4AUJsBKzmMggO7OItqDAP1PHlOIGAGOKp6t1M4MQyuYsV80yxDC8TGb50AiyBOWGjJJ8boV3w== X-YMail-OSG: x2T9SssVM1k9SwT_albW2QR0R5MkuHyo11DHU1kzn5bhAL7hW0awH0G6UFMLeAo DIGjtkB4SV3OhU_78HAecS92911rDnnc9wdMiz3_1vkXlDq6iwLIpvPn0WzSlEQk8hreyjd2qXFH 74XmWyQ3edgXvg.ZCP7AQSPO0Xi3zgneDPIFVmhesazrgvpiiGdl2G7mcHJfhQyz4L51IMpfTsAC kQCEIHoLRjazRGa1xoMrvwJD3Kk.3BLIWfOYgAIzIfyJLjBKK6_4D.HTFtP9wrwYiN5UH57dTnjY pM_HEXTt4UnWnPAPCs8BQL64aQxvsjm5M3gA0nc7Mql9atATtJ.bWQYncCO4CC9_ELLskMP_x_Vw BtdhsaP.B_tiNESKm4iK_7xr93RiCR6Mmk5yO..zgipsA1pLVW0rndBbq9E9shHWDN7OLs_COvZ_ _KQF9POoeKv7FoIEOWLiJk0nr0IDg4U0Ge7VDRVYjFRNBl.Q9KLAYp.N7JzULnEJbIRP4GcAswNm xVZhObsb5Ag5msYYPSO5fP..lJYPgpaWEE0vqCzDDbXnWwYHz4cI1XsAoXlMZ1LKDF8.TxNt4Alx 7MBHrELZy8uSvpTm8FwzZFKE- Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.gq1.yahoo.com with HTTP; Sun, 10 Dec 2017 14:41:16 +0000 Received: from smtpgate102.mail.gq1.yahoo.com (EHLO robicon.homeip.net) ([10.214.153.45]) by smtp407.mail.gq1.yahoo.com (JAMES SMTP Server ) with ESMTPA ID 483445687; Sun, 10 Dec 2017 14:41:12 +0000 (UTC) To: "Gao, Liming" , "edk2-devel@lists.01.org" References: <541697813.1899563.1512848632833.ref@mail.yahoo.com> <541697813.1899563.1512848632833@mail.yahoo.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14E18E292@SHSMSX104.ccr.corp.intel.com> From: Zenith432 Message-ID: <05ee2c7d-b11e-8766-f6e9-fe8d4ae47019@users.sourceforge.net> Date: Sun, 10 Dec 2017 16:41:07 +0200 User-Agent: Thunderbird/52.5 MIME-Version: 1.0 In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E18E292@SHSMSX104.ccr.corp.intel.com> Subject: Re: [PATCH] MdePkg: resolve bug 741 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Dec 2017 14:36:41 -0000 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 10/12/2017 15:52, Gao, Liming wrote: > For 4, 'unsigned char' goes default argument promotion to int. This is CLANG compiler behavior. Does GCC and VS compiler follow this rule? > > Disable varargs warning is the temp solution. For long term, we expect to figure out the compatible solution. If all supported compilers follow this rule, I think this is a compatible change. It is STD C default argument promotion. For example, C99 document n1570 section 6.5.2.2 (Function Calls) "If the expression that denotes the called function has a type that does not include a prototype, the integer promotions are performed on each argument, and arguments that have type float are promoted to double. These are called the default argument promotions." section 6.3.1.1 (Booleans, characters and integers) "If an int can represent all values of the original type (as restricted by the width, for a bit-field), the value is converted to an int; otherwise, it is converted to an unsigned int. These are called the integer promotions." section 7.16.1.4 (The va_start macro) "If the parameter parmN is declared with the register storage class, with a function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions, the behavior is undefined." Technically, when there's a prototype that says the parameter is BOOLEAN (i.e. unsigned char), there is no "promotion" from the point of view of STDC. Instead, it tries to convert the argument to BOOLEAN (if possible.) Then the BOOLEAN is passed using whatever mechanism the implementation has to pass BOOLEANs (which is to fit them in a 4 or 8-byte granular stack). However, va_start wants a parameter type that is the outcome of a default argument promotion, and the outcome of a default argument promotion of 'unsigned char' is always int. There's more discussion with longer quotes from the STD here https://stackoverflow.com/questions/1255775/default-argument-promotions-in-c-function-calls