I committed a change to trunk/apertium that may need a second or third pair
of eyes from someone that knows the code. The relevant diff
http://codepad.org/cpS7wHbT contains 2 changed files, first is a warning,
second is two errors.

The errors are trivial to fix - clang++ defines __GNUC__ so it gets the
array versions of the code which can't compile, so the solution is to only
use the vector version of those parts. Since this is all non-POD anyway, it
doesn't hurt performance.


The warning is less trivial...

hmm.cc:177:22: warning: variable 'k' is uninitialized when used here
      [-Wuninitialized]
  classes_ocurrences[k]++;
hmm.cc:147:14: note: initialize the variable 'k' to silence this warning
  int i, j, k, k1, k2, nw=0;

The obvious fix is to just initialize k to 0, but that changes the logic of
line 177 classes_ocurrences[k]++; and I don't know if the desired effect is
to increment the 0th element or the Mth element (which would be
out-of-bounds) or something else. The whole function (and file) looks like
converted C89 code and could do with scoping fixes and C++ification.


In general, the whole apertium, lttoolbox, etc, codebase could use a few
passes compiled with clang++ and higher warning levels to find and fix
various bugs - there's a lot of dangerous looking warnings, such as

tmx_translate.cc:177:7: warning: variable 'translateLogsPtr' is used
uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  if (logging)

apertium-prelatex.l:217:25: warning: comparison of unsigned expression >= 0
is always true [-Wtautological-compare]
        if(ws.find(L"ngerman") >= 0)

-- Tino Didriksen
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Apertium-stuff mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/apertium-stuff

Reply via email to