On Mon, 15 Nov 2021, Alejandro Colomar (man-pages) via Gcc wrote: > Hi Joseph, > > On 11/15/21 23:17, Joseph Myers wrote: > > On Mon, 15 Nov 2021, Alejandro Colomar (man-pages) via Gcc wrote: > > > > > How is restrict handling that problem of lvalue-to-rvalue already? > > > > restrict has tricky rules about "based on" (6.7.3.1). > > Hmm, I think I can "base on" that, > to define what I had in mind. :)
"based on" is about optimizations; I think it's even less suited to anything relating to diagnostics than it is to optimization. To restrict assignment between different kinds of pointers, I'd think you'd want pointer type variants that differ in some way *other* than qualifiers, a way that's unaffected by lvalue-to-rvalue conversion, but that comes with its own rules on implicit conversion as if by assignment (6.5.16.1) (though then you also need to work out what's allowed in terms of mixing these pointer type variants in all the other operations allowing pointers, what type results of pointer arithmetic have, etc.). And there should surely also be some way of converting a normal pointer to this variant with a runtime check for NULL. Note that discussion of prior art in such a proposal should also consider relevant prior art (for constraining possible values of a variable through the type system) in C++ or other languages if possible. -- Joseph S. Myers jos...@codesourcery.com