This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: [PATCH] Kill 4 warnings, assert()
Paul Eggert <eggert@twinsun.com> writes:
|> > Date: Thu, 4 Jul 2002 18:52:50 +0200 (CEST)
|> > From: Bruno Haible <bruno@clisp.org>
|>
|> > > The use of sizeof can break strictly compliant code.
|> >
|> > How? Can you give an example?
|>
|> Here's a contrived one. This code is strictly conforming.
|>
|> #define NDEBUG
|> #include <assert.h>
|>
|> int main (void)
|> {
|> assert (the rain in spain);
|> return 0;
|> }
A more realistic example would be assertion expressions that use
definitions only available without NDEBUG, something like this:
struct foo {
int n;
#ifndef NDEBUG
int refcnt;
#endif
};
void destroy_foo (struct foo *x)
{
assert (x->refcnt == 0);
free (x);
}
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."