Lemon generates code that does not build with NDEBUG defined.
(1) By anonymous on 2021-11-08 18:58:58 [source]
Hi, not sure where to report this so I am trying it here.
The current version of lemon from fossil trunk generates code that does not build with NDEBUG defined (the version packaged in Ubuntu 18.04 has similar problems, which is why I turned to the source in the first place).
assert.h is only included in lempar.c if NDEBUG is not defined, but there are assert statements outside of #ifndef NDEBUG
blocks.
Similarly, yyRuleName is only declared if NDEBUG is not defined, but it is referenced outside of an #ifndef NDEBUG
block.
Greetings, Christian Henz
(2) By anonymous on 2021-11-08 19:30:51 in reply to 1 [link] [source]
PS, I ended up patching it like this:
diff --git a/lempar.c b/lempar.c
index d5ebe69..0e7175a 100644
--- a/lempar.c
+++ b/lempar.c
@@ -230,6 +230,10 @@ static FILE *yyTraceFILE = 0;
static char *yyTracePrompt = 0;
#endif /* NDEBUG */
+#ifndef assert
+#define assert(x)
+#endif
+
#ifndef NDEBUG
/*
** Turn parser tracing on by giving a stream to which to write the trace
@@ -882,8 +886,8 @@ void Parse(
yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact);
if( yyact >= YY_MIN_REDUCE ){
unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */
- assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
#ifndef NDEBUG
+ assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
if( yyTraceFILE ){
int yysize = yyRuleInfoNRhs[yyruleno];
if( yysize ){
Christian