Re: [edk2] ANSI C bug in MdePkg ProcessorBind.h files for INT8.

Subject: Re: [edk2] ANSI C bug in MdePkg ProcessorBind.h files for INT8.

From: Andrew Fish <afish@apple.com>

To: edk2-devel@lists.sourceforge.net

Date: 2012-03-22 00:43:46

John,

Good points! 

I plan to bring this up to the UEFI spec committee for discussion, and given the UEFI bylaws we can't really have the discussion on this mailing list. 

Andrew Fish


On Mar 21, 2012, at 4:33 PM, John Kearney wrote:

> I know but CHAR8 isn't char if you see what I mean.
> I think it is would save a lot of trouble to just define CHAR8/CHAR16 
> clearly as unsigned.
> there is seriously no valid situation(that I can think of right now), 
> when you want a char to be signed.
> 
> The only time you want char signed is when its being misused as a 
> counter and that should be discouraged anyway and if you really have to 
> do it use INT8.
> 
>  using an 8 bit counter is more legacy, than useful these days anyway. 
> the systems, cpus perform better with their native int types, especially 
> on a IA64/AMD64. you might argue that you save a couple of bytes in the 
> variable but the movzx costs you 1 byte at least not to mention the type 
> overrides necessary.
> 
> 
> 
> Am 22.03.2012 00:20, schrieb Andrew Fish:
>> Kimon,
>> 
>> UEFI defines CHAR8 and CHAR16 as characters. ANSI C is clear that a character type is char, signed char, and unsigned char, and that char is either signed char or unsigned char.  So I think UEFI follows the ambiguity of ANSI C correctly.
>> 
>> It seems the edk2 MdePkg makes an assumption on the sign of a char that is not portable. I'm also concerned that coders are mixing types and the appropriate warnings are not being generated by the compiler.
>> 
>> I'm going to turn off -Wno-sign-compare for clang and post some example warnings to the mailing as soon as I find the time.
>> 
>> Andrew Fish
>> 
>> 
>> 
>> 
>> 
>> On Mar 21, 2012, at 4:00 PM, Berlin, Kimon wrote:
>> 
>>> Would it make sense to amend the UEFI spec to indicate that the signedness of CHAR8 and CHAR16 is undetermined, so they are not to be used for signed math, and to use INT8/UINT8, INT16/UINT16 depending on need?
>>> 
>>> Kimon
>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> This SF email is sponsosred by:
>>> Try Windows Azure free for 90 days Click Here
>>> http://p.sf.net/sfu/sfd2d-msazure
>>> _______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>> 
>> ------------------------------------------------------------------------------
>> This SF email is sponsosred by:
>> Try Windows Azure free for 90 days Click Here
>> http://p.sf.net/sfu/sfd2d-msazure
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
> 
> 
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here 
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel