[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposed support for C1X-style static_assert

From: Paul Eggert
Subject: Re: proposed support for C1X-style static_assert
Date: Thu, 05 May 2011 13:43:40 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110421 Fedora/3.1.9-2.fc14 Thunderbird/3.1.9

On 05/05/11 10:24, Eric Blake wrote:
>> +In C99, @code{assert} can be applied to any scalar expression.
>> > +In C89, the argument to @code{assert} is of type @code{int}.
> Is it worth trying to fix that in gnulib, as an independent fix?  Are
> there any implementations where assert(0x100000000LL) fails instead of
> succeeds, because the conversion from long long back to int lost the
> non-zero bit?

A more interesting case is assert (P) where P is a pointer.
I've written code like that and never had a problem.
(But then, how would I know? :-)

Another case is assert (0.5).  In C89 this must
report an assertion failure, but on all practical
implementations I know of, it succeeds.  So to some extent
that C89 requirement never reflected reality, and the C99
change adjusted the standard to match reality better.

I wouldn't object to fixing 'assert' so that we're sure that
it has C99 semantics, but it's pretty low priority as the
problem, I expect, is only theoretical.  Also, making the
fixed 'assert' report failures in the same way as the original
might prove to be a challenge.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]