checkedint call removal

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 03:23:00 PDT 2014


Walter Bright <newshound2 at digitalmars.com> wrote:
> On 7/30/2014 10:16 PM, bearophile wrote: 
>> But you have redefined "assert" to mean a mix of assume and assert.
> 
> I haven't redefined anything. It's always been that way. It's used that
> way in C/C++ (see your Microsoft C++ link).

Actually I cannot find anything in (the latest draft of) the C standard
that would allow that. There's no mention of undefined behavior if an
assertion is not met with NDEBUG defined. It's clearly defined what the
macro should expnd to in that case.

Quote (Source: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf):
---
The header <assert.h> defines the assert and static_assert macros and
refers to another macro,
NDEBUG
which is not defined by <assert.h>. If NDEBUG is defined as a macro name at
the point in the source file where <assert.h> is included, the assert macro
is defined simply as
#define assert(ignore) ((void)0)
The assert macro is redefined according to the current state of NDEBUG each
time that
<assert.h> is included.
---
And:
---
The assert macro puts diagnostic tests into programs; it expands to a void
expression. When it is executed, if expression (which shall have a scalar
type) is false (that is, compares equal to 0), the assert macro writes
information about the particular call that failed (including the text of
the argument, the name of the source file, the source line number, and the
name of the enclosing function — the latter are respectively the values of
the preprocessing macros __FILE__ and __LINE__ and of the identifier
__func__) on the standard error stream in an implementation-defined
format.191) It then calls the abort function.
---

Tobi


More information about the Digitalmars-d mailing list