On Mon, Sep 21, 2026 at 03:39:22PM +0200, Richard Biener wrote:
> That's fair.
> 
> How would you suggest we can improve -fwrapv-pointer documentation?

Dunno :(

> What does -fwrapv-pointer guarantee?

The mess kernel contains is e.g.
 char *buf, *str, *end;
 size_t size;
...
 str = buf;
 end = buf + size;

 if (end < buf) {
  end = ((void *)-1);
  size = end - buf;
 }

so guess all the option helps is make such code compile somehow.  But
sure, it can't guarantee pretty much anything.
They basically decided to implement sprintf as snprintf with 0x7fffffff
size and that in their implementation does really bad things if called
on a pointer at address higher than (char *)-0x7fffffff.
This was PR82694.

> I'm not sure the kernel used the pointer aspect of -fno-strict-overflow
> conciously or because any concrete "mishandling" of pointers?  Do you
> remember any specific PR?

        Jakub

Reply via email to