On Tue, Nov 10, 2020 at 09:11:08PM +0100, Peter Zijlstra wrote: > On Tue, Nov 10, 2020 at 10:42:58AM -0800, Nick Desaulniers wrote: > > When I think of qualifiers, I think of const and volatile. I'm not > > sure why the first post I'm cc'ed on talks about "segment" qualifiers. > > Maybe it's in reference to a variable attribute that the kernel > > defines? Looking at Clang's Qualifier class, I see const, volatile, > > restrict (ah, right), some Objective-C stuff, and address space > > (TR18037 is referenced, I haven't looked up what that is) though maybe > > "segment" pseudo qualifiers the kernel defines expand to address space > > variable attributes? > > Right, x86 Named Address Space: > > > https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Named-Address-Spaces.html#Named-Address-Spaces > > Also, Google found me this: > > https://reviews.llvm.org/D64676 > > The basic problem seems to be they act exactly like qualifiers in that > typeof() preserves them, so if you have:
GCC has the four standard type qualifiers (const, volatile, restrict, and _Atomic), but also the address space things yes. > > Maybe stripping all qualifiers is fine since you can add them back in > > if necessary? > > So far that seems sufficient. Although the Devil's advocate in me is > trying to construct a case where we need to preserve const but strip > volatile and that's then means we need to detect if the original has > const or not, because unconditionally adding it will be wrong. If you want to drop all qualifiers, you only need a way to convert something to an rvalue (which always has an unqualified type). So maybe make syntax for just *that*? __builtin_unqualified() perhaps? Which could be useful in more places than just doing an unqualified_typeof. Segher