From: Ethan M. <merritt@u.washington.edu> - 2012-08-28 04:24:07
|
On Monday, 27 August 2012, Mojca Miklavec wrote: > Hello, > > I'm sending a bunch of compiler warnings for gnuplot from two > different compilers. The first batch comes from Sparc Solaris, the > second one from clang on Mac OS X 10.7 (most warnings are recent, in > particular those about plot2d; the last three are older). Thanks. I'm using clang also, but it hasn't given me these particular warnings. Almost all look like either false positives or utter trivia. The emf.trm declarations should be fixed, however. The lua.trm and wxt_gui.cpp ones I do not understand. "datafile.c", line 448: warning: syntax error: empty declaration EAM: True, but so what? "datafile.c", line 642: warning: statement not reached EAM: True, and it's even commented as such in the source "set.c", line 1444: warning: argument #2 is incompatible with prototype: prototype: pointer to pointer to const char : "/opt/csw/include/iconv.h", line 83 argument : pointer to pointer to char EAM: Feh. Ignore all warnings about "const char" That's not even our code - that's a system header. "../term/emf.trm", line 344: warning: initializer does not fit or is out of range: -5 EAM: This one is a true hit, however. It looks to me that a dozen or so of the declarations at the top of emf.trm are marked "unsigned" for no good reason. But why only complain about this one and not 10 others? "../term/hpgl.trm", line 2580: warning: statement not reached EAM: OK "../term/lua.trm", line 469: warning: initialization type mismatch EAM: I have absoluately no idea what this one is about. "term.c", line 2159: warning: tokens ignored at end of directive line EAM: ignore it "wxterminal/wxt_gui.cpp", line 1669: Warning (Anachronism): Formal argument 1 of type extern "C" void(*)() in call to std::atexit(extern "C" void(*)()) is being passed void(*)(). "wxterminal/wxt_gui.cpp", line 3831: Warning (Anachronism): Formal argument 2 of type extern "C" void(*)(int) in call to std::signal(int, extern "C" void(*)(int)) is being passed void(*)(int). "wxterminal/wxt_gui.cpp", line 3866: Warning (Anachronism): Formal argument 2 of type extern "C" void(*)(int) in call to std::signal(int, extern "C" void(*)(int)) is being passed void(*)(int). "wxterminal/wxt_gui.cpp", line 3866: Warning (Anachronism): Assigning extern "C" void(*)(int) to void(*)(int). "wxterminal/wxt_gui.cpp", line 3875: Warning (Anachronism): Formal argument 2 of type extern "C" void(*)(int) in call to std::signal(int, extern "C" void(*)(int)) is being passed void(*)(int). 5 Warning(s) detected. EAM: Is it saying that you can't pass a C routine as a C++ parameter? Really? "gplt_x11.c", line 634: warning: initializer does not fit or is out of range: 129 "gplt_x11.c", line 635: warning: initializer does not fit or is out of range: 136 "gplt_x11.c", line 636: warning: initializer does not fit or is out of range: 255 "gplt_x11.c", line 637: warning: initializer does not fit or is out of range: 128 "gplt_x11.c", line 638: warning: initializer does not fit or is out of range: 128 "gplt_x11.c", line 639: warning: initializer does not fit or is out of range: 136 "gplt_x11.c", line 640: warning: initializer does not fit or is out of range: 136 EAM: These make no sense to me. ../../original/src/plot2d.c:821:7: warning: array index of '-1' indexes before the beginning of the array [-Warray-bounds] COLOR_STORE_WITH_LOG_AND_UPDATE_RANGE(cp->CRD_COLOR, v[2], cp->type, [snip lots of fallout] EAM: These warnings are known false positives as noted in the ChangeLog. The compiler is simply not smart enough to notice that the negative array index can never happen in practice. The following patch suppresses the warnings, but I don't like it because it introduces unneeded code into one of the few true hot paths in the program. Also I'm not 100% that all C compilers will accept and optimize the #VARNAME syntax. --- gnuplot/src/axis.h 2012-08-05 21:12:03.000000000 -0700 +++ gnuplot-cvs/src/axis.h 2012-08-07 13:17:43.000000000 -0700 @@ -539,7 +539,8 @@ break; /* this plot is not being used for autoscaling */ \ if (TYPE != INRANGE) \ break; /* don't set y range if x is outrange, for example */ \ - if (axis->linked_to_primary) { \ + /* NB: we hope for compile-time evaluation of the strcmp */ \ + if (strcmp(#AXIS,"COLOR_AXIS") && axis->linked_to_primary) { \ axis = &axis_array[AXIS - SECOND_AXES]; \ if (axis->link_udf->at) \ curval = eval_link_function(AXIS - SECOND_AXES, curval); \ |