Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nwchem-7.2.3 on Fedora42: hdbm.c:610:9: error: expected identifier or '(' before 'false' #1072

Open
marcindulak opened this issue Jan 25, 2025 · 1 comment
Assignees
Labels

Comments

@marcindulak
Copy link

Describe the bug

For 8701f25, the compilation fails on Fedora42, gcc version 15.0.1 20250114 (Red Hat 15.0.1-0) (GCC), with

Compiling hdbm.c...
hdbm.c: In function ‘delete_file_entry’:
hdbm.c:610:9: error: expected identifier or ‘(’ before ‘false’
  610 |     int false = 0;
      |         ^~~~~
hdbm.c:619:30: error: lvalue required as unary ‘&’ operand
  619 |     if (hdbm_fwrite((char *) &false, sizeof(false), (size_t) 1, file) != 1) {
      |                              ^

Reported at https://bugzilla.redhat.com/show_bug.cgi?id=2340948

To Reproduce

  1. Run docker build --progress=plain -t test:latest ., using the following Dockerfile
# docker build --progress=plain -t test:latest .
  
FROM fedora:42@sha256:70d5934128fe1b1abc97750dc358dad9cf499c11059f0ed720872fedcc4880d1

RUN set -x \
    && dnf install -y gcc \
    && dnf clean all

RUN set -x \
    && uname -a

RUN set -x \
    && cat /etc/*release | grep PRETTY

RUN set -x \
    && gcc -v

RUN set -x \
    && curl -sL https://github.com/nwchemgit/nwchem/raw/refs/heads/master/src/rtdb/hdbm/hdbm.c -o /tmp/hdbm.c \
    && curl -sL https://github.com/nwchemgit/nwchem/raw/refs/heads/master/src/rtdb/hdbm/hdbm.h -o /tmp/hdbm.h

RUN cd /tmp && gcc -c hdbm.c

CMD ["/bin/bash"]

Expected behavior

Successful build.

@edoapra
Copy link
Collaborator

edoapra commented Jan 25, 2025

It sounds like a bug in the compiler parser to me, confused by the false variable name.
If you replace the false variable name with something else, gcc-15 does not throw an error.
Here is the Dockerfile

# docker build --progress=plain -t test:latest .

FROM fedora:42@sha256:70d5934128fe1b1abc97750dc358dad9cf499c11059f0ed720872fedcc4880d1

RUN set -x \
    && dnf install -y gcc patch \
    && dnf clean all

RUN set -x \
    && uname -a

RUN set -x \
    && cat /etc/*release | grep PRETTY

RUN set -x \
    && gcc -v

RUN set -x \
    && curl -sL https://github.com/nwchemgit/nwchem/raw/refs/heads/master/src/rtdb/hdbm/hdbm.c -o /tmp/hdbm.c \
    && curl -sL https://github.com/nwchemgit/nwchem/raw/refs/heads/master/src/rtdb/hdbm/hdbm.h -o /tmp/hdbm.h

RUN cat > /tmp/hdbm_false.patch <<EOF
diff --git a/hdbm.c b/hdbm.c
index 5e0170e..38211b1 100644
--- a/hdbm.c
+++ b/hdbm.c
@@ -607,7 +607,7 @@ static int delete_file_entry(hdbm db, entry *e)
     file_entry fe;
     long act_ptr = e->rec_ptr +
 	(long) (((char *) &fe.active) - ((char *) &fe));
-    int false = 0;
+    int flse = 0;
     int ind;

     if (hdbm_fseek(file, act_ptr, SEEK_SET)) {
@@ -616,7 +616,7 @@ static int delete_file_entry(hdbm db, entry *e)
 	return 0;
     }

-    if (hdbm_fwrite((char *) &false, sizeof(false), (size_t) 1, file) != 1) {
+    if (hdbm_fwrite((char *) &flse, sizeof(flse), (size_t) 1, file) != 1) {
 	fprintf(stderr, "delete_file_entry: failed to inactivate header\n");
 	return 0;
     }
EOF

RUN cd /tmp && patch -p1 < /tmp/hdbm_false.patch

RUN cd /tmp && gcc -c hdbm.c

CMD ["/bin/bash"]

@edoapra edoapra self-assigned this Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants