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

gcc-13 runtime error #461

Closed
apelloni opened this issue Nov 1, 2023 · 4 comments
Closed

gcc-13 runtime error #461

apelloni opened this issue Nov 1, 2023 · 4 comments

Comments

@apelloni
Copy link

apelloni commented Nov 1, 2023

I was building (t)form on my machine which is currently using gcc (GCC) 13.2.1 20230801 and found an error.
The compilation is completed without any issues (except some warnings see form_build_gcc13.log)

Most programs run just fine, but I get an error with tables. By running

Table sparse,C(1);
.end

I get

test.frm Line 1 --> Illegal option in table definition: 'sparse,C(1)'

I've tried to build form-5.0.0, form-4.3.1, form-4.3.0 but the issue is consistent.

It all disappear when I compile with gcc-12 (GCC) 12.3.0 by running CC=gcc-12 CXX=g++-12 ./configure
Then the program runs as expected.

I've also tried to enable debugging but then vorm runs without issues.
So I've tried to compile with a lower optimization level and I found that -O2 and -O3 are the ones producing the issue

I'm unsure if this is a problem in the gcc compiler or something being exposed only at this level.
It could also be that the version I'm using is not completely stable.
I also didn't have the opportunity to try to reproduce it on another machine

I'm attaching also the output from make form using both gcc-12 and gcc-13:
form_build_gcc13.log
form_build_gcc12.log

@tueda
Copy link
Collaborator

tueda commented Nov 1, 2023

Thank you for your report! I have confirmed the same FORM runtime error with GCC 13.2.0.

I am not sure whether GCC 13 finds a pitfall in the FORM code (e.g., legal optimization with undefined behaviour) or it is just a bug of GCC, but it seems that making c volatile somehow removes the issue:

diff --git a/sources/names.c b/sources/names.c
index fd01e89..9ae586f 100644
--- a/sources/names.c
+++ b/sources/names.c
@@ -1666,7 +1666,8 @@ static int nwarntab = 1;
 int DoTable(UBYTE *s, int par)
 {
        GETIDENTITY
-       UBYTE *name, *p, *inp, c;
+       UBYTE *name, *p, *inp;
+       volatile UBYTE c;
        int i, j, k, sparseflag = 0, rflag = 0, checkflag = 0;
        int error = 0, ret, oldcbufnum, oldEside;
        WORD funnum, type, *OldWork, *w, *ww, *t, *tt, *flags1, oldnumrhs,oldnumlhs;

Maybe we need C (and/or GCC) experts...

@tueda
Copy link
Collaborator

tueda commented Nov 2, 2023

Posted a related question on StackOverflow.

@tueda
Copy link
Collaborator

tueda commented Nov 3, 2023

To summarize the discussion on StackOverflow, this is a GCC 13 bug and will be fixed in 13.3.0. So, I close this issue.

Meanwhile, we must not forget to run make check (test_Issue135_3 catches this issue).

@tueda tueda closed this as completed Nov 3, 2023
@apelloni
Copy link
Author

apelloni commented Nov 3, 2023

I've run make check but didn't show any error.
I've looked into the check files and saw that check-help.sh calls for ruby which I didn't have installed.
Now I can also see the failed check.

Thanks for looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants