Package: libc0.3-dev
Version: 2.42-14~hurd.1
I discovered this problem while trying to build mongo-c-driver 2.2.3 to
get rsyslog into Debian. I was able to reproduce it using a simple C
code fragment. When using debuild and building this fragment of
src/common/src/common-b64.c
int
mcommon_b64_pton(char const *src, uint8_t *target, size_t targsize)
{
static bson_once_t once = BSON_ONCE_INIT;
bson_once(&once, bson_b64_initialize_rmap);
it expands to
static pthread_once_t once =
# 503 "/home/pere/src/mongo-c-driver-2.2.3/src/common/src/common-b64.c" 3 4
(struct __pthread_once) { 0, 0 }
# 503 "/home/pere/src/mongo-c-driver-2.2.3/src/common/src/common-b64.c"
;
do { do { if (!(__builtin_expect(!!(pthread_once((&once),
(bson_b64_initialize_rmap)) == 0), 1))) {
_bson_assert_failed_on_line("./src/common/src/common-b64.c", (int)(505),
__func__, "pthread_once((&once), (bson_b64_initialize_rmap)) == 0"); } } while
(0); } while (0);
which cause this error:
/home/user/mongo-c-driver-2.2.3/src/common/src/common-b64.c: In
function '_bson_mcommon_b64_pton':
/home/user/mongo-c-driver-2.2.3/src/common/src/common-b64.c:503:30:
error: initializer element is not constant [-Werror=pedantic]
503 | static bson_once_t once = BSON_ONCE_INIT;
| ^~~~~~~~~~~~~~
According to
<URL:
https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/pthread_once.html
>
the value of PTHREAD_ONCE_INIT should be constant. Is it not so on GNU
Hurd? I fail to understand how { 0, 0} is not constant, but even a
small test program demonstrate the problem:
% cat x.c
#include <pthread.h>
int main(int argc, char *argv[]) {
static pthread_once_t once = PTHREAD_ONCE_INIT;
return 0;
}
% gcc -Werror -pedantic x.c
x.c: In function 'main':
x.c:3:32: error: initializer element is not constant [-Werror=pedantic]
3 | static pthread_once_t once = PTHREAD_ONCE_INIT;
| ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
%
This is using gcc 15.2.0 and an update Debian Hurd based on Sid.
--
Happy hacking
Petter Reinholdtsen