LearnFrenzy
Sign in Take a free test

Error Handling · Error Handling MCQ · Question 8

What happens to assert() when NDEBUG is defined? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

What happens to assert(x > 0) if NDEBUG is defined before including <assert.h>?

  • A It always aborts
  • B It expands to nothing – the expression is not evaluated at all Correct
  • C It prints a warning and continues
  • D It becomes a static_assert
Correct Answer: Option B

Release builds commonly define NDEBUG. That is why asserts must not contain side effects and must not replace real input validation.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links