The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Albert Cahalan <albert@users.sf.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Albert Cahalan <albert@users.sourceforge.net>,
	linux-kernel mailing list <linux-kernel@vger.kernel.org>,
	bunk@fs.tum.de, arjanv@redhat.com, axboe@suse.de
Subject: Re: What policy for BUG_ON()?
Date: 31 Aug 2004 13:39:37 -0400	[thread overview]
Message-ID: <1093973977.434.7097.camel@cube> (raw)
In-Reply-To: <Pine.LNX.4.58.0408310945580.2295@ppc970.osdl.org>

On Tue, 2004-08-31 at 12:52, Linus Torvalds wrote:
> On Tue, 31 Aug 2004, Albert Cahalan wrote:
> > 
> > The normal expectation for non-debug builds
> > would be this:
> > 
> > #define BUG_ON(x)
> 
> No, this is bad, for one big reason: it generates compiler
> warnings if 'x' happens to be the only thing that uses some value.
...
> This is generally why you should have macros like this not
> become empty, but become something that the compiler can
> compile away. Which is why I'd much rather see
> 
> 	#define BUG_ON(x) (void)(x)
> 
> regardless of any side-effect issues - it's a way to let the
> compiler optimize the thing away, but still show that
> something was used at least "conceptually"..

Expensive function calls won't get optimized away unless you
mark them __attribute__((__const__)) or __attribute__((__pure__)).
(perhaps that should be encouraged)

Then of course the compiler must assume that the function
really needed the arguments it was passed, and that it
might have modified memory, and so on.

Eh, how about a BUG_ON_WITH_SIDE_EFFECT() macro?



  reply	other threads:[~2004-08-31 17:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-31 15:06 What policy for BUG_ON()? Albert Cahalan
2004-08-31 16:52 ` Linus Torvalds
2004-08-31 17:39   ` Albert Cahalan [this message]
2004-08-31 21:30     ` Kyle Moffett
2004-08-31 22:16       ` Michael Buesch
2004-08-31 23:32         ` Kyle Moffett
  -- strict thread matches above, loose matches on Subject: below --
2004-08-30 20:15 Adrian Bunk
2004-08-30 20:22 ` Arjan van de Ven
2004-08-31  6:28   ` Jens Axboe
2004-08-31 11:14     ` Paulo Marques
2004-08-31  0:25 ` Linus Torvalds
2004-08-31 11:28   ` Adrian Bunk

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=1093973977.434.7097.camel@cube \
    --to=albert@users.sf.net \
    --cc=albert@users.sourceforge.net \
    --cc=arjanv@redhat.com \
    --cc=axboe@suse.de \
    --cc=bunk@fs.tum.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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