Skip to content

Commit 1e89b0b

Browse files
authored
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)
1 parent aba38d1 commit 1e89b0b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vlib/v/gen/c/cheaders.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ const c_common_macros = '
360360
361361
// for __offset_of
362362
#ifndef __offsetof
363-
#define __offsetof(PTYPE,FIELDNAME) ((size_t)((char *)&((PTYPE *)0)->FIELDNAME - (char *)0))
363+
#define __offsetof(PTYPE,FIELDNAME) ((size_t)(&((PTYPE *)0)->FIELDNAME))
364364
#endif
365365
366366
#define OPTION_CAST(x) (x)

0 commit comments

Comments
 (0)