Ard: The below condition can't be trigged. It is in the else path of #elif defined(__GNUC__). So, #if defined(__GNUC__) is always FALSE in below case. Are they added for comment only?
Thanks Liming > -----Original Message----- > From: edk2-devel [mailto:[email protected]] On Behalf Of > Ard Biesheuvel > Sent: Sunday, July 17, 2016 6:35 PM > To: [email protected]; [email protected]; [email protected]; Gao, > Liming <[email protected]>; Shi, Steven <[email protected]>; Zhu, > Yonghong <[email protected]>; Kinney, Michael D > <[email protected]>; Justen, Jordan L <[email protected]> > Cc: [email protected]; [email protected]; Ard Biesheuvel > <[email protected]>; Ye, Ting <[email protected]>; Long, Qin > <[email protected]> > Subject: [edk2] [PATCH v3 6/9] MdePkg: disallow open coded varargs > implementation on optimizing GCC > > The open coded varargs implementation that performs pointer arithmetic on > the last named parameter of a function to calculate the addresses of > variadic parameters and subsequently derefences them is fragile, and break > spectacularly when used under GCC with optimization enabled. So explicitly > disallow this combination. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel <[email protected]> > --- > MdePkg/Include/Base.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h > index e03fa8239284..95400f993e6b 100644 > --- a/MdePkg/Include/Base.h > +++ b/MdePkg/Include/Base.h > @@ -635,6 +635,11 @@ typedef __builtin_va_list VA_LIST; > #endif > > #else > + > +#if defined(__GNUC__) && defined(__OPTIMIZE__) > +#error This VA_LIST implementation is incompatible with GCC optimization > +#endif > + > /// > /// Variable used to traverse the list of arguments. This type can vary by > /// implementation and could be an array or structure. > -- > 1.9.1 > > _______________________________________________ > edk2-devel mailing list > [email protected] > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

