Skip to content

Commit

Permalink
Disable incorrect gcc warning
Browse files Browse the repository at this point in the history
Locally I get:
```
In file included from /home/rag/Documents/Code/julia/usr/include/llvm/Object/ObjectFile.h:18,
                 from /home/rag/Documents/Code/julia/usr/include/llvm/DebugInfo/DIContext.h:18,
                 from /home/rag/Documents/Code/julia/src/debuginfo.cpp:6:
In function 'bool llvm::operator==(llvm::StringRef, llvm::StringRef)',
    inlined from 'bool llvm::operator!=(llvm::StringRef, llvm::StringRef)' at /home/rag/Documents/Code/julia/usr/include/llvm/ADT/StringRef.h:874:71,
    inlined from 'objfileentry_t find_object_file(uint64_t, llvm::StringRef)' at /home/rag/Documents/Code/julia/src/debuginfo.cpp:948:43,
    inlined from 'bool jl_dylib_DI_for_fptr(size_t, llvm::object::SectionRef*, int64_t*, llvm::DIContext**, bool, bool*, uint64_t*, void**, char**, char**)' at /home/rag/Documents/Code/julia/src/debuginfo.cpp:1135:34:
/home/rag/Documents/Code/julia/usr/include/llvm/ADT/StringRef.h:871:20: warning: 'int __builtin_memcmp_eq(const void*, const void*, long unsigned int)' specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overread]
  871 |     return ::memcmp(LHS.data(), RHS.data(), LHS.size()) == 0;
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/rag/Documents/Code/julia/src/debuginfo.cpp: In function 'bool jl_dylib_DI_for_fptr(size_t, llvm::object::SectionRef*, int64_t*, llvm::DIContext**, bool, bool*, uint64_t*, void**, char**, char**)':
/home/rag/Documents/Code/julia/src/debuginfo.cpp:1133:11: note: source object allocated here
 1133 |     fname = dlinfo.dli_fname;
 ```

 On CI:
```
In file included from /cache/build/builder-amdci4-2/julialang/julia-master/usr/include/llvm/Object/ObjectFile.h:18,
                 from /cache/build/builder-amdci4-2/julialang/julia-master/usr/include/llvm/DebugInfo/DIContext.h:18,
                 from /cache/build/builder-amdci4-2/julialang/julia-master/src/debuginfo.cpp:6:
In function 'bool llvm::operator==(llvm::StringRef, llvm::StringRef)',
    inlined from 'bool llvm::operator!=(llvm::StringRef, llvm::StringRef)' at /cache/build/builder-amdci4-2/julialang/julia-master/usr/include/llvm/ADT/StringRef.h:874:71,
    inlined from 'objfileentry_t find_object_file(uint64_t, llvm::StringRef)' at /cache/build/builder-amdci4-2/julialang/julia-master/src/debuginfo.cpp:943:43,
    inlined from 'bool jl_dylib_DI_for_fptr(size_t, llvm::object::SectionRef*, int64_t*, llvm::DIContext**, bool, bool*, uint64_t*, void**, char**, char**)' at /cache/build/builder-amdci4-2/julialang/julia-master/src/debuginfo.cpp:1126:47:
/cache/build/builder-amdci4-2/julialang/julia-master/usr/include/llvm/ADT/StringRef.h:871:20: error: 'int __builtin_memcmp_eq(const void*, const void*, long unsigned int)' specified size 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
  871 |     return ::memcmp(LHS.data(), RHS.data(), LHS.size()) == 0;
      |            ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
  • Loading branch information
Zentrik committed Oct 13, 2024
1 parent c7eac60 commit 7b8bfda
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/debuginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ using namespace llvm;
#include "julia_assert.h"
#include "debug-registry.h"

#ifdef _COMPILER_GCC_
// GCC is throwing warnings like `warning: 'int __builtin_memcmp_eq(const void*, const void*, long unsigned int)' specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807` in llvm's StringRef.h == seemingly because it doesn't realise the size can't be 0.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overread"
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif

static JITDebugInfoRegistry *DebugRegistry = new JITDebugInfoRegistry;

static JITDebugInfoRegistry &getJITDebugRegistry() JL_NOTSAFEPOINT {
Expand Down Expand Up @@ -1644,3 +1651,7 @@ uint64_t jl_getUnwindInfo_impl(uint64_t dwAddr)
jl_unlock_profile();
return ipstart;
}

#ifdef _COMPILER_GCC_
#pragma GCC diagnostic pop
#endif

0 comments on commit 7b8bfda

Please sign in to comment.