Skip to content

Document assert_(), combine with __ASSERT_; fixup Perl_assert() #23543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: blead
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions perl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5096,14 +5096,17 @@ Gid_t getegid (void);
/* Keep the old croak based assert for those who want it, and as a fallback if
the platform is so heretically non-ANSI that it can't assert. */

#define Perl_assert(what) PERL_DEB2( \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit Cleanup Perl_assert definition

I would slightly alter the commit message and add something like:

For reference: PERL_DEB2 is defined as:

#ifdef DEBUGGING
#  define PERL_DEB2(a,b)               a
#else /* ! DEBUGGING below */
#  define PERL_DEB2(a,b)               b
#endif /* DEBUGGING */

(I had no clue what PERL_DEB2 did so had to look it up before I could review the change)

((what) ? ((void) 0) : \
(Perl_croak_nocontext("Assertion %s failed: file \"" __FILE__ \
"\", line %d", STRINGIFY(what), __LINE__), \
(void) 0)), ((void)0))

/* assert() gets defined if DEBUGGING.
* If no DEBUGGING, the <assert.h> has not been included. */
#ifdef DEBUGGING
# define Perl_assert(what) \
((what) \
? ((void) 0) \
: Perl_croak_nocontext("Assertion %s failed:" \
" file \"" __FILE__ "\", line %" LINE_Tf, \
STRINGIFY(what), (line_t) __LINE__))
#else
# define Perl_assert(what) ((void) 0)
#endif

#ifndef assert
# define assert(what) Perl_assert(what)
#endif
Expand Down