From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932117Ab2JBAzc (ORCPT ); Mon, 1 Oct 2012 20:55:32 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:41522 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751946Ab2JBAza (ORCPT ); Mon, 1 Oct 2012 20:55:30 -0400 MIME-Version: 1.0 In-Reply-To: <1348874411-28288-11-git-send-email-daniel.santos@pobox.com> References: <1348874411-28288-1-git-send-email-daniel.santos@pobox.com> <1348874411-28288-11-git-send-email-daniel.santos@pobox.com> Date: Mon, 1 Oct 2012 17:55:26 -0700 Message-ID: Subject: Re: [PATCH 10/10] bug.h: Add gcc 4.2+ versions of BUILD_BUG_ON_* macros From: Michel Lespinasse To: Daniel Santos Cc: LKML , Andi Kleen , Andrea Arcangeli , Andrew Morton , Christopher Li , David Daney , David Howells , Joe Perches , Konstantin Khlebnikov , linux-sparse@vger.kernel.org, Paul Gortmaker , Pavel Pisa , Peter Zijlstra , Steven Rostedt Content-Type: text/plain; charset=ISO-8859-1 X-System-Of-Record: true Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 28, 2012 at 4:20 PM, Daniel Santos wrote: > BUILD_BUG_ON42(arg) > BUILD_BUG_ON_CONST42(arg) > > Prior to gcc 4.2, the optimizer was unable to determine that many > constant values stored in structs were indeed compile-time constants and > optimize them out. Sometimes, it will find an intergral value to be a > compile-time constant, but fail to perform a bit-wise AND at > compile-time. These two macros provide a mechanism to perform these > build-time checks, but not break on older compilers where we already > know they can't be checked at compile time. > > For specific details, consult the doc comments for BUILD_BUG_ON_CONST. > These macros are used in the generic rbtree code. I think the names are quite confusing. BUILD_BUG_ON_NON_CONST42 sounds like it's checking if 42 is a constant. The name probably shouldn't mention what compiler versions support this check, but instead it should hint as to when you should use this instead of BUILD_BUG_ON_CONST ? Maybe BUILD_BUG_ON_CONST_DEREF or something (I'm pretty bad with names too :) -- Michel "Walken" Lespinasse A program is never fully debugged until the last user dies.