On Sat, Mar 14, 2026 at 03:44:08PM +0100, Ingo Saitz wrote: > On Sat, Mar 14, 2026 at 02:50:46PM +0100, Ingo Saitz wrote: > > I attached [...] > > Grml, here you go > > Ingo > -- > const_cast<long double>(Λ)
> From 552485b879d19780afd3614d69508c3ea7cb242f Mon Sep 17 00:00:00 2001 > From: Ingo Saitz <[email protected]> > Date: Sat, 14 Mar 2026 14:24:56 +0100 > Subject: [PATCH] Replace CONST_CAST with const_cast<>. > > For gcc-16, this was removed in gcc trunk > > see commits > c3d96ff9e916c02584aa081f03ab999292efbb50 > 458c7926d48959abcb2c1adaa22458e27459a551 > --- > scripts/gcc-plugins/gcc-common.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/scripts/gcc-plugins/gcc-common.h > b/scripts/gcc-plugins/gcc-common.h > index 8f1b3500f8e2..7b3517b31e0a 100644 > --- a/scripts/gcc-plugins/gcc-common.h > +++ b/scripts/gcc-plugins/gcc-common.h > @@ -309,7 +309,7 @@ typedef const gimple *const_gimple_ptr; > #define gimple gimple_ptr > #define const_gimple const_gimple_ptr > #undef CONST_CAST_GIMPLE > -#define CONST_CAST_GIMPLE(X) CONST_CAST(gimple, (X)) > +#define CONST_CAST_GIMPLE(X) const_cast<gimple>((X)) > > /* gimple related */ > static inline gimple gimple_build_assign_with_ops(enum tree_code subcode, > tree lhs, tree op1, tree op2 MEM_STAT_DECL) > @@ -414,7 +414,7 @@ static inline void ipa_remove_stmt_references(symtab_node > *referring_node, gimpl > #ifdef __cplusplus > static inline void debug_tree(const_tree t) > { > - debug_tree(CONST_CAST_TREE(t)); > + debug_tree(const_cast<tree>(t)); > } > > static inline void debug_gimple_stmt(const_gimple s) > @@ -422,7 +422,7 @@ static inline void debug_gimple_stmt(const_gimple s) > debug_gimple_stmt(CONST_CAST_GIMPLE(s)); > } > #else > -#define debug_tree(t) debug_tree(CONST_CAST_TREE(t)) > +#define debug_tree(t) debug_tree(const_cast<tree>(t)) > #define debug_gimple_stmt(s) debug_gimple_stmt(CONST_CAST_GIMPLE(s)) > #endif 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). Is const_cast<gimple> and const_cast<tree> valid back through GCC 8 (earliest Linux-supported GCC)? -Kees -- Kees Cook

