Need a way to make PR_ASSERT work in optimized builds

RESOLVED FIXED in 4.2

Status

NSPR
NSPR
P1
enhancement
RESOLVED FIXED
16 years ago
16 years ago

People

(Reporter: ruslan, Assigned: Wan-Teh Chang)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

16 years ago
Need a way to make PR_ASSERT work in optimized builds.
(Assignee)

Comment 1

16 years ago
This is a good idea.

In hindsight, I shouldn't have used the DEBUG macro to
control the expansion of PR_ASSERT.  I should have used
NDEBUG (which controls the libc 'assert' macro) or some
other macro such as PR_NDEBUG.

If we want to use NDEBUG, this must be done in the next
NSPR major release.

If we are willing to use a new macro (PR_NDEBUG) for this
purpose, we can do this in the next NSPR minor release
(4.2).
Severity: major → enhancement
Status: NEW → ASSIGNED
Priority: -- → P1
Target Milestone: --- → Future
Version: 4.1.3 → 4.1.2
(Reporter)

Comment 2

16 years ago
We don't really have to have PR_ASSERT's inside of NSPR working in optimized 
builds. Would be fine if PR_ASSERT will work when used and certain debug define 
is set (say PR_USE_ASSERT_ALWAYS or smth like that). Why do we need to wait for 
a major release for this?
(Assignee)

Comment 3

16 years ago
Ruslan, you are right.  If we are just going to add another
macro (FORCE_PR_ASSERT, following the naming convention of
similar macros) that would also enable PR_ASSERT, this does
not need to be done in a major release.  That is, we would
say:
#if defined(DEBUG) || defined(FORCE_PR_ASSERT)

#define PR_ASSERT(expr) a-working-definition

#else

#define PR_ASSERT(expr) ((void) 0)

#endif

What I wanted to do was to use only one macro, NDEBUG or
PR_NDEBUG (what I said about PR_NDEBUG was actually wrong),
to control PR_ASSERT.  This would need to be done in a major
release.  That is, we would say:
#if !defined(PR_NDEBUG)

#define PR_ASSERT(expr) a-working-definition

#else

#define PR_ASSERT(expr) ((void) 0)

#endif
(Assignee)

Updated

16 years ago
Target Milestone: Future → 4.2
(Assignee)

Comment 4

16 years ago
Created attachment 62780 [details] [diff] [review]
Proposed patch.  PR_ASSERT is enabled if DEBUG or FORCE_PR_ASSERT is defined.

Ruslan, please give this patch a try.
(Assignee)

Comment 5

16 years ago
Comment on attachment 62780 [details] [diff] [review]
Proposed patch.  PR_ASSERT is enabled if DEBUG or FORCE_PR_ASSERT is defined.

I checked in the patch on the tip and client branch of
NSPR.  It will be in NSPR 4.2 Beta.
(Assignee)

Comment 6

16 years ago
Marked the bug fixed.
Status: ASSIGNED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.