On Thu. 5 Dec. 2024 at 08:58, Kees Cook <kees@xxxxxxxxxx> wrote: > On December 3, 2024 3:33:22 AM GMT+10:00, Vincent Mailhol via B4 Relay <devnull+mailhol.vincent.wanadoo.fr@xxxxxxxxxx> wrote: > >This series is the spiritual successor of [1] which introduced > >const_true(). In [1], following a comment from David Laight, Linus > >came with a suggestion to simplify __is_constexpr() and its derived > >macros using a _Generic() selection. Because of the total change of > >scope, I am starting a new series. > > > >The goal is to introduce a set of three macros: > > > > - is_const(): a one to one replacement of __is_constexpr() in term > > of features but written in a less hacky way thanks to _Generic(). > > > > - is_const_true(): tells whether or not the argument is a true > > integer constant expression. > > > > - is_const_false(): tells whether or not the argument is a false > > integer constant expression. > > But why make this change? Is something broken? Does it make builds faster? > > > 7 files changed, 97 insertions(+), 84 deletions(-) > > It makes the code larger too. I don't see what the benefit is, and given how much time has been spent making sure the existing stuff works correctly, I feel like we should have a clear benefit to replacing it all. It makes the "code" larger because patch 3 ("compiler.h: add is_const_true() and is_const_false()") adds two new macros with 20 lines of comments to explain the pros and cons. So the added "code" is only comments. If you ignore the comments, you can see that I am actually removing a few lines of code. As for the clear benefit, sorry, but I have nothing more to offer other than code simplification. The reason why a lot of time was spent to make __is_constexpr() work correctly is just a testimony of how complex the thing is. That alone can be a reason to simplify it, now that new tools (_Generic()) are available. Of course, modifying __is_constexpr() is not strictly needed to introduce the new is_const_expr(). My previous series: https://lore.kernel.org/all/20241113172939.747686-4-mailhol.vincent@xxxxxxxxxx/ did it that way. But I was rightfully pointed out for my macro being ugly. Maybe I can suggest that you give a look to the above thread and tell me if you still disagree with David and Linus's comments after reading it? Yours sincerely, Vincent Mailhol