Issue localized. Surprised that anyone with /W4 /WX on MS VC does not see this, 
since this code can be seen by any X64 build that I can try.  MSVC detects that 
the union of an auto variable exceeds the storage on the stack.

The problem is that word0 uses the following union:



1.       typedef union { double d; ULong L[2]; } U; (gdtoaimp.h)

2.       Now, ULong is typedef'd to UINTN. (see EfiCdefs.h)

3.       word0() is #define word0(x) ( /* LINTED */ (U*)&x)->L[1] (gdtoaimp.h)

4.       And rv is a double:  double aadj, aadj1, adj, rv, rv0; (strtod.c, line 
96) In MSVC, this is 8 bytes.

Now, the line in question is line 825:

825:        word0(rv) = (UINT32)(L | Bndry_mask1);

Which ends up being

((U *)&rv)->L[1] = (UINT32)(L | Bndry_mask1);

L[1] ends up being offset 8 (64 bits) into rv, which is past the end of the 
double, thus the warning. That explaines why word1(x) works fine.

There is a piece of commented-out code in line 287 of gdatoimp.h which uses a 
UINT32 instead of a ULong, which appears to be correct.  After commenting out 
line 286 and including line 287, the code builds without warning.

Thanks,

Tim



From: Tim Lewis [mailto:tim.le...@insyde.com]
Sent: Monday, October 22, 2012 2:42 PM
To: edk2-devel@lists.sourceforge.net
Subject: [edk2] strod issues

Anyone seen these before? I can get them in one config but not another. In X64 
word0 evaluates to a UINTN *

d:\bios\kernel\05.02.40\stdlib\libc\gdtoa\strtod.c(825) : error C2220: warning 
treated as error - no 'object' file generated
d:\bios\kernel\05.02.40\stdlib\libc\gdtoa\strtod.c(825) : warning C4789: 
destination of memory copy is too small
d:\bios\kernel\05.02.40\stdlib\libc\gdtoa\strtod.c(785) : warning C4789: 
destination of memory copy is too small
d:\bios\kernel\05.02.40\stdlib\libc\gdtoa\strtod.c(905) : warning C4789: 
destination of memory copy is too small
d:\bios\kernel\05.02.40\stdlib\libc\gdtoa\strtod.c(499) : warning C4789: 
destination of memory copy is too small
d:\bios\kernel\05.02.40\stdlib\libc\gdtoa\strtod.c(473) : warning C4789: 
destination of memory copy is too small

They all seem to come from lines like this:

825:        word0(rv) = (UINT32)(L | Bndry_mask1);
785:          word0(rv) = (word0(rv) & Exp_mask)
            + Exp_msk1
#ifdef IBM
            | Exp_msk1 >> 4
#endif
            ;

905:                word0(rv) = Big0;
499:                word0(rv) = (P+2)*Exp_msk1;
473:                word0(rv) = Big0;

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to