On Fri, Mar 20, 2026 at 12:23:10PM -0700, Kees Cook wrote:
> Thanks for this!
>
> Should CONST_CAST_TREE be explicitly defined instead, to match
> CONST_CAST_GIMPLE in the this header file? It seems weird to have one of
> two done this way: we should either do both or neither (CONST_CAST_GIMPLE
> is only used in the header file too).
My first idea was to simplay guard this depending on the gcc version,
since the CONST_CAST_TREE type changed from (union tree_node *) to tree.
But the typedef union tree_node *tree (in gcc source: gcc/coretypes.h)
is already there in gcc-8, and const_cast is an old c++ feature.
> Is const_cast<gimple> and const_cast<tree> valid back through GCC 8
> (earliest Linux-supported GCC)?
I successfully compiled and booted linux 6.19.8 with my patch applied
with gcc-8 (Debian 8.3.0-7) 8.3.0, so it think this patch does work with
all supported gcc versions and a guard is not needed indeed.
I tried to minimize the changes, since I don't really know how gcc
plugins actually work. But changing CONST_CAST_GIMPLE to
const_cast<gimple>, too, should not fail since that's now a simple text
replacement.
Ingo
--
const_cast<long double>(Λ)