On Tue, Nov 10, 2020 at 08:57:42AM +0100, Peter Zijlstra wrote: > On Mon, Nov 09, 2020 at 11:50:15AM -0800, Nick Desaulniers wrote: > > On Mon, Nov 9, 2020 at 11:46 AM Segher Boessenkool > > <seg...@kernel.crashing.org> wrote: > > > On Mon, Nov 09, 2020 at 01:47:13PM +0100, Peter Zijlstra wrote: > > > > C in general does not provide means to strip qualifiers. > > > > > > Most ways you can try to use the result are undefined behaviour, even. > > > > Yes, removing `const` from a `const` declared variable (via cast) then > > expecting to use the result is a great way to have clang omit the use > > from the final program. This has bitten us in the past getting MIPS > > support up and running, and one of the MTK gfx drivers. > > Stripping const to delcare another variable is useful though. Sure C has > sharp edges, esp. if you cast stuff, but since when did that stop anyone > ;-)
My point is that removing most qualifiers usually is a problem, so before doing this, we should think if it is such a good plan, whether there is a safer / saner solution, etc. Segher