[libcxx-commits] [libcxx] [libc++] Fix bogus integer sanitizer warnings in hash helpers (PR #146715)

Jean-Michaƫl Celerier via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 3 15:20:46 PDT 2025


jcelerier wrote:

here's for instance all the warnings I get whenever I start my app just coming from this place:

```

/usr/bin/../include/c++/v1/__functional/hash.h:133:64: runtime error: left shift of 17751278790833232267 by 21 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:133:64 
/usr/bin/../include/c++/v1/__functional/hash.h:137:40: runtime error: left shift of 7738135736995832184 by 55 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:137:40 
/usr/bin/../include/c++/v1/__functional/hash.h:137:40: runtime error: left shift of 5642809484591583822 by 53 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:137:40 
/usr/bin/../include/c++/v1/__functional/hash.h:137:40: runtime error: left shift of 8314892262689629553 by 50 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:137:40 
/usr/bin/../include/c++/v1/__functional/hash.h:137:40: runtime error: left shift of 8461812133216675204 by 48 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:137:40 
/usr/bin/../include/c++/v1/__functional/hash.h:133:64: runtime error: left shift of 13621769879915339144 by 21 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:133:64 
/usr/bin/../include/c++/v1/__functional/hash.h:137:40: runtime error: left shift of 7809631459534666091 by 54 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:137:40 
/usr/bin/../include/c++/v1/__functional/hash.h:133:64: runtime error: left shift of 8773319506221311228 by 21 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:133:64 
/usr/bin/../include/c++/v1/__functional/hash.h:133:64: runtime error: left shift of 18129537700234053450 by 12 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:133:64 
/usr/bin/../include/c++/v1/__functional/hash.h:133:64: runtime error: left shift of 15310047686210979080 by 21 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:133:64 
/usr/bin/../include/c++/v1/__functional/hash.h:133:64: runtime error: left shift of 17062917676620572615 by 21 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:133:64 
/usr/bin/../include/c++/v1/__functional/hash.h:137:40: runtime error: left shift of 8389209267074581617 by 52 places cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../include/c++/v1/__functional/hash.h:137:40 
```

whenever I start lldb I have to sift through all of those which gets fairly frustrating quickly..

https://github.com/llvm/llvm-project/pull/146715


More information about the libcxx-commits mailing list