Ticket #9917 (closed defect: fixed)
ECL has too few arguments and two many on file dpp.c
| Reported by: | drkirkby | Owned by: | GeorgSWeber |
|---|---|---|---|
| Priority: | major | Milestone: | sage-4.6 |
| Component: | build | Keywords: | ecl |
| Cc: | jhpalmieri | Work issues: | |
| Report Upstream: | Fixed upstream, in a later stable release. | Reviewers: | John Palmieri |
| Authors: | David Kirkby, Leif Leonhardy | Merged in: | sage-4.6.alpha2 |
| Dependencies: | Stopgaps: |
Description (last modified by drkirkby) (diff)
When I'm building ecl-10.2.1 as part of Sage I get too warning messages from gcc.
/export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p2/src/src/c/dpp.c: In function 'put_declaration': /export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p2/src/src/c/dpp.c:678:5: warning: too few arguments for format /export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p2/src/src/c/dpp.c:680:13: warning: too many arguments for format
Looking at line 678 of dpp.c, I see:
fprintf(out, "\tif (ecl_unlikely(narg!=%d))");
So there's a %d, but what is associate with the %d? There should be an integer, but there is not one. So it seems to me gcc is right to complain there are too few arguments for format.
Likewise, on line 680, I see:
fprintf(out, "\t FEwrong_num_arguments(MAKE_FIXNUM(%d));\n",
nreq, function_code);
There we observe two arguments supplied, but only one %d is there. That does not make any sense to me. Both "nreq" and "function_code" are declared as integers, so should there not two %d's and not one.
Again, it seems gcc is right to complain that.
There are thousands of warning messages in Sage, but I'm a bit concerned about resolving those in ecl, as the ecl library being built has text relocation problems - see #9840
Dave
Attachments
Change History
comment:2 Changed 3 years ago by leif
Perhaps temporarily fix this in Sage's 10.2.1 by patching it to the obvious:
fprintf(out, "\tif (ecl_unlikely(narg!=%d))", nreq);
and
fprintf(out, "\t FEwrong_num_arguments(MAKE_FIXNUM(%d));\n", function_code);
(You don't have to report this upstream since it is already fixed.)
comment:3 Changed 3 years ago by drkirkby
Yes, I just downloaded the latest ecl using "git" and it is indeed fixed upstream. I'll create a package with the upstream fixes to these two lines of code. It will remove two warnings. I doubt it is the cause of my relocation problems, but at least it will not leave me wondering if it is.
comment:4 Changed 3 years ago by drkirkby
- Status changed from new to needs_info
- Authors set to David Kirkby, Leif Leonhardy
Now when this is compiled, the warnings messages have gone:
gcc -I/export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p3/src/src/c -I/export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p3/src/build -I./ /export/home/drkirkby/sage-4.6.alpha0/spkg/build/ecl-10.2.1.p3/src/src/c/dpp.c -I/export/home/drkirkby/sage-4.6.alpha0/local/include -O2 -g -Wall -fPIC -Dsun4sol2 -o dpp
An updated package can be found at
http://boxen.math.washington.edu/home/kirkby/patches/ecl-10.2.1.p3.spkg
This needs further testing, as I've only currently tested this on OpenSolaris, but I think it is as safe as a bank vault. Hence for now I've marked it "needs info" until such time as I can confirm it works fully on other systems.
Dave
Changed 3 years ago by drkirkby
-
attachment
9917-makes-changes-to-dpp.c.patch
added
Makes acouple of changes to the file dpp.c, which will remove a couple of compiler warnings which looked potentially harmful.
comment:5 Changed 3 years ago by drkirkby
- Cc jhpalmieri added
- Status changed from needs_info to needs_review
- Report Upstream changed from N/A to Fixed upstream, but not in a stable release.
I've checked this now on OpenSolaris, Solaris 10 on SPARC (t2). Linux (sage.math) and OS X (bsd.math).
ECL installed ok on all of them. Maxima failed on OS X, but the failure is already known - see #8645.
As such, I'm now marking this for review. I don't know whether fixing these compiler warnings will solve the problems on Solaris (I doubt it will), but its not a good idea to have code like it was before.
Since this is already fixed upstream in their git repository, I've marked it as such.
Dave
comment:6 follow-up: ↓ 11 Changed 3 years ago by jhpalmieri
In the spkg, the file dpp.c.patch is empty. That should be fixed. Other than that, the changes look fine. I'll test it on a few systems, but I can't imagine there being a problem.
Regarding
fprintf(out, "\t FEwrong_num_arguments(MAKE_FIXNUM(%d));\n",
nreq, function_code);
I find it amusing that this problem occurs in a line containing "wrong_num_arguments"...
comment:7 Changed 3 years ago by leif
It's also fixed in 10.4.1, which I think is a stable release.
That's called "Literal programming" I think, self-referential.
comment:8 Changed 3 years ago by leif
-
src/src/c/dpp.c
diff -Nu ecl-10.2.1.p1/src/src/c/dpp.c ecl-10.4.1/src/src/c/dpp.c
old new 251 251 } 252 252 253 253 char * 254 search_symbol(char *name, int *symbol_code )254 search_symbol(char *name, int *symbol_code, int code) 255 255 { 256 256 int i; 257 257 for (i = 0; cl_symbols[i].name != NULL; i++) { 258 258 if (!strcasecmp(name, cl_symbols[i].name)) { 259 259 name = poolp; 260 if (i == 0) { 260 if (code) { 261 pushstr("MAKE_FIXNUM(/*"); 262 pushstr(cl_symbols[i].name); 263 pushstr("*/"); 264 if (i >= 1000) 265 pushc((i / 1000) % 10 + '0'); 266 if (i >= 100) 267 pushc((i / 100) % 10 + '0'); 268 if (i >= 10) 269 pushc((i / 10) % 10 + '0'); 270 pushc(i % 10 + '0'); 271 pushstr(")"); 272 pushc(0); 273 } else if (i == 0) { 261 274 pushstr("Cnil"); 262 275 pushc(0); 263 276 } else { … … 283 296 } 284 297 285 298 char * 286 read_symbol( )299 read_symbol(int code) 287 300 { 288 301 char c, *name = poolp; 302 char end = code? ']' : '\''; 289 303 290 304 c = readc(); 291 while (c != '\'') {305 while (c != end) { 292 306 if (c == '_') c = '-'; 293 307 pushc(c); 294 308 c = readc(); 295 309 } 296 310 pushc(0); 297 311 298 name = search_symbol(poolp = name, 0 );312 name = search_symbol(poolp = name, 0, code); 299 313 if (name == NULL) { 300 314 name = poolp; 301 315 printf("\nUnknown symbol: %s\n", name); … … 387 401 } else if (c == '@') { 388 402 c = readc(); 389 403 if (c == '\'') { 390 (void)read_symbol(); 404 (void)read_symbol(0); 405 poolp--; 406 } else if (c == '[') { 407 (void)read_symbol(1); 391 408 poolp--; 392 409 } else if (c == '@') { 393 410 pushc(c); … … 448 465 get_function(void) 449 466 { 450 467 function = read_function(); 451 function_symbol = search_symbol(function, &function_code );468 function_symbol = search_symbol(function, &function_code, 0); 452 469 if (function_symbol == NULL) { 453 470 function_symbol = poolp; 454 471 pushstr("Cnil"); … … 675 692 } 676 693 if (nopt == 0 && !rest_flag && !key_flag) { 677 694 put_lineno(); 678 fprintf(out, "\tif (ecl_unlikely(narg!=%d))" );695 fprintf(out, "\tif (ecl_unlikely(narg!=%d))", nreq); 679 696 fprintf(out, "\t FEwrong_num_arguments(MAKE_FIXNUM(%d));\n", 680 nreq,function_code);697 function_code); 681 698 } else { 682 699 simple_varargs = !rest_flag && !key_flag && ((nreq + nopt) < 32); 683 700 if (key_flag) { … … 833 850 } else if (c == '\'') { 834 851 char *p; 835 852 poolp = pool; 836 p = read_symbol(); 853 p = read_symbol(0); 854 pushc('\0'); 855 fprintf(out,"%s",p); 856 goto LOOP; 857 } else if (c == '[') { 858 char *p; 859 poolp = pool; 860 p = read_symbol(1); 837 861 pushc('\0'); 838 862 fprintf(out,"%s",p); 839 863 goto LOOP;
If that convinces you more.
Changed 3 years ago by drkirkby
-
attachment
9917-non-empty-patch-file.patch
added
Somehow the previous patch file I made was empty - this corrects that.
comment:10 Changed 3 years ago by drkirkby
I've updated the patch file - I've no idea how I managed to make it empty before!
There are of course several changes to the upstream code, but since the snapshot I took was an unstable release, I think it is wise to limit the changes to just what were causing a problem in Sage.
I'm not sure if there is a later stable release available or not - I've found the version number at the top right of the ECL web site rarely agrees with the version number one can actually download. I think we probably have the latest stable release due to a comment made by Juanjo on the ECL mailing list in my response to my question about this matter.
Sage cannot rely on unstable releases, which is why I was slowly working on another stable release -- unfortunately actual work got in the way.
Juanjo
I've updated the .spkg at
http://boxen.math.washington.edu/home/kirkby/patches/ecl-10.2.1.p3.spkg
Dave
comment:11 in reply to: ↑ 6 Changed 3 years ago by drkirkby
Replying to jhpalmieri:
I find it amusing that this problem occurs in a line containing "wrong_num_arguments"...
Yes the line in ECL is rather funny. It's a bit like that ATLAS file make_correct_shared.sh, which seems to screw up making the shared libraries!
Dave
comment:12 Changed 3 years ago by jhpalmieri
- Status changed from needs_review to positive_review
- Reviewers set to John Palmieri
comment:13 Changed 3 years ago by leif
- Report Upstream changed from Fixed upstream, but not in a stable release. to Fixed upstream, in a later stable release.
comment:14 Changed 3 years ago by mpatel
- Status changed from positive_review to closed
- Resolution set to fixed
- Merged in set to sage-4.6.alpha2
