[cfe-dev] ISO C3X proposal: nonnull qualifier

Joseph Myers via cfe-dev cfe-dev at lists.llvm.org
Thu Dec 2 12:36:48 PST 2021


On Thu, 2 Dec 2021, Alejandro Colomar (man-pages) via Gcc wrote:

> So, now this can be made non-flow-sensitive, which was a big concern. And now
> the biggest concern I can see is that this qualifier works opposite to const
> (here discarding is allowed but not adding it), and that is contrary to how

For all existing qualifiers, the rules about discarding are rules about 
permitted assignments (and conversions as if by assignment) between 
pointers and concern the qualifiers on pointer target types: 6.5.16.1 is 
the key subclause concerning implicit conversions, and any proposal for 
changes in that area needs to be precise about exactly what textual 
changes are proposed to 6.5.16.1.

> compilers have been working for now.  As far as I could read in the standard,
> there's no mention to qualifiers being dropped in an rvalue; Joseph, could you
> please confirm?  Also, as I already mentioned, Clang already implements this

lvalue-to-rvalue conversion drops qualifiers (and _Atomic).  "If the 
lvalue has qualified type, the value has the unqualified version of the 
type of the lvalue; additionally, if the lvalue has atomic type, the value 
has the non-atomic version of the type of the lvalue; otherwise, the value 
has the type of the lvalue." (6.3.2.1).

-- 
Joseph S. Myers
joseph at codesourcery.com


More information about the cfe-dev mailing list