[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLgiP2DRcGy04YdsWS9+N1=_CCNEtAGrCn31vUHjnDLW9xw@mail.gmail.com>
Date: Fri, 12 Sep 2025 11:45:16 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
Cc: Andrew Ballance <andrewjballance@...il.com>, Joel Fernandes <joelagnelf@...dia.com>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
John Hubbard <jhubbard@...dia.com>, Alexandre Courbot <acourbot@...dia.com>, Timur Tabi <ttabi@...dia.com>,
Alistair Popple <apopple@...dia.com>, Miguel Ojeda <ojeda@...nel.org>
Subject: Re: Printing with overflow checks can cause modpost errors
On Fri, Sep 12, 2025 at 10:28 AM Miguel Ojeda
<miguel.ojeda.sandonis@...il.com> wrote:
>
> On Fri, Sep 12, 2025 at 6:08 AM Andrew Ballance
> <andrewjballance@...il.com> wrote:
> >
> > The pointer passed is const so rustc should assume that the c side does
> > not change offset, but looks like rustc does not do that.
>
> That is not possible -- a const pointer does not guarantee the value
> will not be changed.
I believe this code is using an immutable reference and not just a
pointer, so it would be UB to use it to write to `offset`, and so it
would be valid to assume it has not changed. But I think that in most
scenarios, Rust only optimizes using that information when the
reference appears as a function argument, which is not the case here.
Alice
Powered by blists - more mailing lists