We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0190cd2 commit 5e2c059Copy full SHA for 5e2c059
1 file changed
mypyc/irbuild/vec.py
@@ -236,6 +236,12 @@ def vec_len_native(builder: LowLevelIRBuilder, val: Value) -> Value:
236
237
238
def vec_items(builder: LowLevelIRBuilder, vecobj: Value) -> Value:
239
+ """Return pointer to first item in vec's buf.
240
+
241
+ The caller must ensure buf is not NULL (i.e., vec is non-empty).
242
+ Empty vecs have buf=NULL, and computing &NULL->items is undefined
243
+ behavior that GCC -O3 can exploit to miscompile surrounding code.
244
+ """
245
vtype = cast(RVec, vecobj.type)
246
buf = builder.get_element(vecobj, "buf")
247
return builder.add(GetElementPtr(buf, vtype.buf_type, "items"))
0 commit comments