On Mon, Sep 18, 2023 at 4:49 PM Floyd, Paul via Gcc <gcc@gcc.gnu.org> wrote: > > Hi Richard and Jonathan > > On 18/09/2023 10:00, Richard Biener wrote: > > On Mon, Sep 18, 2023 at 9:24 AM Jonathan Wakely via Gcc<gcc@gcc.gnu.org> > > wrote: > >> Yes, GCC assumes that the reference is bound to a valid object, because C++ > >> requires that to be true. Of course memcheck can't assume that, because one > >> of its main reasons to exist is to find undefined behaviour where that > >> isn't true! > > It's even worse than that. This transformation is being done in VEX > (which unfortunately > is also the bit I know the least). Not normally where we'd do > accessibility checks. > > >> I think what GCC is doing is a valid transformation, in the context of a > >> valid C++ program. But I'm not sure that helps valgrind, which doesn't have > >> the liberty of assuming a valid program. > > More specifically GCC thinks it's fine to speculate loads (given it can > > prove > > doing so doesn't trap) > > I don't think that will be easy for us to prove. We just don't know > enough about stack variables.
What you could do is report the access only on the point of use of the accessed value? (and disregard when the register holding the value is re-used) Richard. > A+ > > Paui