From 1e89b0b0ddb50d863021f40cdcd4719c90c95743 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sat, 7 Oct 2023 11:54:45 +0200 Subject: [PATCH] cgen: don't subtract null ptr in `__offsetof`, fix for `v -cstrict -cc clang-14 cmd/tools/vpm.v` and other programs using `import net.http` (fix #19222) (#19520) --- vlib/v/gen/c/cheaders.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vlib/v/gen/c/cheaders.v b/vlib/v/gen/c/cheaders.v index 8f5c6bff9aed76..d3e8b4e7152bcc 100644 --- a/vlib/v/gen/c/cheaders.v +++ b/vlib/v/gen/c/cheaders.v @@ -360,7 +360,7 @@ const c_common_macros = ' // for __offset_of #ifndef __offsetof - #define __offsetof(PTYPE,FIELDNAME) ((size_t)((char *)&((PTYPE *)0)->FIELDNAME - (char *)0)) + #define __offsetof(PTYPE,FIELDNAME) ((size_t)(&((PTYPE *)0)->FIELDNAME)) #endif #define OPTION_CAST(x) (x)