public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
	jbeulich@novell.com, rusty@rustcorp.com.au, rguenther@suse.de
Cc: arnd@arndb.de
Subject: [PATCH] Fix BUILD_BUG_ON in fs/compat_ioctl.c to build with gcc 4.5 snapshot
Date: Sun, 20 Dec 2009 17:53:15 +0100	[thread overview]
Message-ID: <20091220165315.GA13208@basil.fritz.box> (raw)

Fix BUILD_BUG_ON in fs/compat_ioctl.c to build with gcc 4.5 snapshot

The BUILD_BUG_ON in compat_ioctl_check_table() fails
with a recent gcc mainline snapshot (gcc version 4.5.0 20091219)
(GCC)), even though it works with older compilers.

 const int max = ARRAY_SIZE(ioctl_pointer) - 1;
 BUILD_BUG_ON(max >= (1 << 16));

I replaced the BUILD_BUG_ON with a old style extern reference and 
that works.

That shows that the actual expression is evaluated ok and something must be 
wrong with the BUILD_BUG_ON macro itself. Maybe Rusty's rework
will fix that (I haven't tried but it's probably worth investigating) 

I filed a bug on the compiler too 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42439

According to Joseph Myers the problem is that even when declared
with const "max" is not a constant expression in the C standard sense,
so the code is indeed incorrect.

Anyways with this workaround a relatively standard defconfig like 
configuration and a 64bit allyes configuration builds again with gcc 4.5

Cc: jbeulich@novell.com
Cc: rusty@rustcorp.com.au
Cc: rguenther@suse.de

Signed-off-by: Andi Kleen <ak@linux.intel.com>

---
 fs/compat_ioctl.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6.33-rc1-ak/fs/compat_ioctl.c
===================================================================
--- linux-2.6.33-rc1-ak.orig/fs/compat_ioctl.c
+++ linux-2.6.33-rc1-ak/fs/compat_ioctl.c
@@ -1649,8 +1649,10 @@ static int compat_ioctl_check_table(unsi
 {
 	int i;
 	const int max = ARRAY_SIZE(ioctl_pointer) - 1;
+	extern void __ioctl_pointer_too_large(void);
 
-	BUILD_BUG_ON(max >= (1 << 16));
+	if (max >= (1 << 16))
+		__ioctl_pointer_too_large();
 
 	/* guess initial offset into table, assuming a
 	   normalized distribution */

             reply	other threads:[~2009-12-20 16:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-20 16:53 Andi Kleen [this message]
2009-12-21 10:32 ` [PATCH] Fix BUILD_BUG_ON in fs/compat_ioctl.c to build with gcc 4.5 snapshot Rusty Russell
2009-12-21 10:51   ` Andi Kleen
2009-12-21 23:44     ` Rusty Russell
2009-12-22  0:13       ` Andi Kleen
2009-12-21 16:48 ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091220165315.GA13208@basil.fritz.box \
    --to=andi@firstfloor.org \
    --cc=arnd@arndb.de \
    --cc=jbeulich@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rguenther@suse.de \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox