From c34f496600287c1a48b1fcdde6c5d26e9da1646e Mon Sep 17 00:00:00 2001 From: John Reiser Date: Fri, 7 Apr 2017 05:36:40 -0700 Subject: [PATCH] Avoid incorrect C4319 by Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64 modified: p_lx_elf.cpp --- src/p_lx_elf.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 6e357c8c..54856d5f 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -1512,7 +1512,12 @@ bool PackLinuxElf32::canPack() if (1!=exetype && phdr->PT_LOAD32 == p_type) { // 1st PT_LOAD exetype = 1; load_va = get_te32(&phdr->p_vaddr); // class data member - unsigned const off = ~page_mask & load_va; + + // Cast on next line is to avoid a compiler bug (incorrect complaint) in + // Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64 + // error C4319: '~': zero extending 'unsigned int' to 'upx_uint64_t' of greater size + unsigned const off = ~page_mask & (unsigned)load_va; + if (off && off == p_offset) { // specific hint throwCantPack("Go-language PT_LOAD: try hemfix.c, or try '--force-execve'"); // Fixing it inside upx fails because packExtent() reads original file.