tianocore / edk2

EDK II
https://github.com/tianocore/tianocore.github.io/wiki/EDK-II
Other
4.54k stars 2.45k forks source link

BaseTools fails to compile with Xcode 7.3 #89

Closed al3xtjames closed 8 years ago

al3xtjames commented 8 years ago

Compilation of BaseTools (make -C BaseTools) fails with Xcode 7.3 (on OS X 10.11.4) due to negative shifts in FvLib.c.

FvLib.c:197:128: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
  *NextFile = (EFI_FFS_FILE_HEADER *) ((((UINTN) CurrentFile - (UINTN) mFvHeader + GetFfsFileLength(CurrentFile) + 0x07) & (-1 << 3)) + (UINT8 *) mFvHeader);
                                                                                                                            ~~ ^
FvLib.c:482:171: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
    CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetSectionFileLength(CurrentSection.CommonHeader) + 0x03) & (-1 << 2));
                                                                                                                                                                       ~~ ^

-Wno-shift-negative-value could be added to the Makefile to suppress the errors. The negative shifts could also be replaced.

ajfish commented 8 years ago

From a pedantic point of view shifting negative numbers is undefined behavior in C so the correct fix is casting to an unsigned value. Thus -1 should be -1U (or -1ULL), this is a better fix that suppressing the warning.

lersek commented 8 years ago

Duplicate of https://github.com/tianocore/edk2/issues/49, closing.