[ruby-core:104957] [Ruby master Bug#18076] ext/digest/md5/md5.c: `-Wnull-pointer-subtraction` warning by Clang 13
From:
"xtkoba (Tee KOBAYASHI)" <noreply@...>
Date:
2021-08-17 17:39:05 UTC
List:
ruby-core #104957
Issue #18076 has been updated by xtkoba (Tee KOBAYASHI).
Proposed patch:
```diff
--- a/ext/digest/md5/md5.c
+++ b/ext/digest/md5/md5.c
@@ -225,7 +225,7 @@
uint32_t xbuf[16];
const uint32_t *X;
- if (!((data - (const uint8_t *)0) & 3)) {
+ if (!(((uintptr_t)data) & 3)) {
/* data are properly aligned */
X = (const uint32_t *)data;
} else {
```
----------------------------------------
Bug #18076: ext/digest/md5/md5.c: `-Wnull-pointer-subtraction` warning by Clang 13
https://bugs.ruby-lang.org/issues/18076#change-93319
* Author: xtkoba (Tee KOBAYASHI)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.1.0dev (2021-08-16T00:07:09Z master 4cc44bd819) [x86_64-linux]
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
```
compiling ../../../../ext/digest/md5/md5.c
../../../../ext/digest/md5/md5.c:228:17: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
if (!((data - (const uint8_t *)0) & 3)) {
^ ~~~~~~~~~~~~~~~~~~
1 warning generated.
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>