Page MenuHome GnuPG

c23 boolean issue in GPG asschk.c
Closed, ResolvedPublic

Description

in c23 "true" is a reserved word. There is a test in GPG's tests/asschk.c that uses a local variable "true" for storing the value "1", fiddling around with it, and then eventually returning a boolean value. The following patch simply renames it to 'tr' which allows for compilation under gcc with -std=gnu2x

Details

Version
2.4.5

Event Timeline

--- gnupg-2.4.5/tests/asschk.c	2023-04-04 02:28:39.000000000 -0600
+++ gnupg-2.4.5-c23/tests/asschk.c	2024-04-19 21:21:36.460724329 -0600
@@ -656,13 +656,13 @@
 static int
 eval_boolean (const char *cond)
 {
-  int true = 1;
+  int tr = 1;
 
   for ( ; *cond == '!'; cond++)
-    true = !true;
+    tr = !tr;
   if (!*cond || (*cond == '0' && !cond[1]))
-    return !true;
-  return true;
+    return !tr;
+  return tr;
 }
jeffcliff renamed this task from c23 boolean issue in asschk.c to c23 boolean issue in GPG asschk.c.Apr 20 2024, 5:56 AM
jeffcliff updated the task description. (Show Details)
werner claimed this task.
werner added a project: gnupg.
werner added a subscriber: werner.

Okay, fix pushed to master, 2.4, and 2.2. Thanks.

Introducing a new keyword into C was a Bad Idea™. Should have been hidden behind a pragma.