On 10/08/12 10:05, Sergey Isakov wrote:
> Hi sirs,
> I encounter next problem.
> ----------
> c:\tiano\edk2\mdepkg\library\baselib\math64.c(89) : warning C6334:
> sizeof operator applied to an expression with an operator might yield
> unexpected results.
> ----------
> The code is the follow
> ------
>   //
>   // Test if this compiler supports arithmetic shift
>   //
>   TestValue = (((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1));
>   if (TestValue == -1) {
>     //
>     // Arithmetic shift is supported
> 
> ------
> It seems VS2012 don't like sizeof(-1).
> Switch off some warning?

>From search results for this warning message, VS2012 apparently warns
that the operand of the sizeof operator is not evaluated.

ISO C99 6.5.3.4 The sizeof operator

    2 [...] If the type of the operand is a variable length array type,
      the operand is evaluated; otherwise, the operand is not evaluated
      [...]

However, VS2012 should rather warn about the sub-expression below,
because it invokes undefined behavior (C99 6.5.7p4):

    (-1) << (sizeof (-1) * 8 - 1)

Laszlo

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to