[PATCH] More helpful result of NOT_REACHED assertion

--MP_/QMf9D+u8vT.wfwSo0ZBDJEj
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Before:
  perl5.31.2: op.c:1921: Perl_scalar: Assertion `0' failed.

"0" isn't very descriptive.

After:
  perl5.31.2: op.c:1921: Perl_scalar: Assertion `!"UNREACHABLE"' failed.

A little more helpful as it immediately reminds you this is an
unreachable statement that was reached.

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

--MP_/QMf9D+u8vT.wfwSo0ZBDJEj
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename=0001-Print-a-more-helpful-UNREACHABLE-message-when-NOT_RE.patch

From ba7115678138ca9a416ebf8aea61241e11b12362 Mon Sep 17 00:00:00 2001
From: "Paul \"LeoNerd\" Evans" <leonerd@leonerd.org.uk>
Date: Wed, 3 Jul 2019 17:19:10 +0100
Subject: [PATCH] Print a more helpful UNREACHABLE message when NOT_REACHED
 assertion fails

---
 perl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/perl.h b/perl.h
index a82d055733..f5f18ff4f7 100644
--- a/perl.h
+++ b/perl.h
@@ -3509,9 +3509,9 @@ EXTERN_C int perl_tsa_mutex_unlock(perl_mutex* mutex)
 #  define NOT_REACHED
 #elif defined(DEBUGGING) && (__has_builtin(__builtin_unreachable) \
      || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5 || __GNUC__ > 4)) /* 4.5 -> */
-#  define NOT_REACHED STMT_START { ASSUME(0); __builtin_unreachable(); } STMT_END
+#  define NOT_REACHED STMT_START { ASSUME(!"UNREACHABLE"); __builtin_unreachable(); } STMT_END
 #else
-#  define NOT_REACHED ASSUME(0)
+#  define NOT_REACHED ASSUME(!"UNREACHABLE")
 #endif
 
 /* Some unistd.h's give a prototype for pause() even though
-- 
2.20.1


--MP_/QMf9D+u8vT.wfwSo0ZBDJEj--
0
leonerd
7/3/2019 4:20:39 PM
perl.perl5.porters 47702 articles. 1 followers. Follow

0 Replies
12 Views

Similar Articles

[PageSpeed] 28

Reply: