Skip to content

Commit d386a55

Browse files
authored
[libc] Make static_assert available even if NDEBUG is set (#99742)
This addresses an issue introduced in #98826 where static_assert was made defined only when NDEBUG is not set which is different from all other C libraries and breaks any code that uses static_assert and doesn't guard it with NDEBUG.
1 parent 867ff2d commit d386a55

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

libc/include/assert.h.def

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,19 @@
1212
// This file may be usefully included multiple times to change assert()'s
1313
// definition based on NDEBUG.
1414

15-
16-
#undef assert
17-
#ifdef NDEBUG
18-
#define assert(e) (void)0
19-
#else
20-
2115
#ifndef __cplusplus
2216
#undef static_assert
2317
#define static_assert _Static_assert
2418
#endif
2519

20+
#undef assert
21+
#ifdef NDEBUG
22+
#define assert(e) (void)0
23+
#else
2624
#ifdef __cplusplus
2725
extern "C"
2826
#endif
2927
_Noreturn void __assert_fail(const char *, const char *, unsigned, const char *) __NOEXCEPT;
30-
3128
#define assert(e) \
3229
((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
3330
#endif

0 commit comments

Comments
 (0)