This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Remove `attr != NULL' assert in allocate_stack.
The purpose of asserts is partly documentation, which can also be served by
comments but asserts are self-testing against bit-rot as comments cannot
be. The main purpose is to ensure that intended assumptions of the code
are not accidentally violated by changes elsewhere, which is a common
source of subtle bugs. Even if the caller and callee seem intimately tied
now, they might not seem so obviously so to someone else touching the code
months or years from now.
In the particular case of an assumption that a pointer is not null, just
the fact that the code (unconditionally) uses the pointer is sufficient as
an assert (though not necessarily as documentation), since it will reliably
and straightforwardly crash.