On 19/05/2017 04:31, Steve D'Aprano wrote:
On Fri, 19 May 2017 04:17 am, bartc wrote:

There is one uninitialised variable reported. And that is used only in
an error situation. But yes, that was a mistake.

"Only one"?
....

Its a bit naughty to claim "one" uninitialized variable when there are
somewhere between 10 and 28.

I thought you were compiling qcc32.c not pcc32.c.


> [steve@ando langs]$ gcc -Wall -m32 -O3 qlang/pcc32.c -opcc -lm 2>&1 | grep
> uninitialized | head

Which gcc version? I can't get mine (5.1.0) to report any of these, even with -Wall -Wextra -Wpedantic.

> qlang/pcc32.c:8952: warning: ‘c’ may be used uninitialized in this function

Take this example. The code fragment is this:

        n = p->objptr->length;
        if (!n) {
            return 0;
        }
        hsum = csum = 0;
        s = p->objptr->strptr;
        av_9 = n;
        while (av_9--) {
            c = (uchar)*s++;
            csum += c;
            hsum = (hsum<<2)+c;
        }
        return (c+(hsum<<3)^csum^c)&2147483647;

I assume it's concerned about the use of 'c' on the last line, because it is only initialised in the conditional while loop. It thinks that that the loop may be executed zero times. But it is executed n times; the case of n being zero is taken care of earlier on.

I checked a few others, and they are not serious (one is in a debugging function that is never called from example).

I'll take care of both programs I think by putting the word 'experimental' back in the comments. Originally such files were just demonstrations of how reasonably substantial programs (around 10% the size of CPython sources as it might have been then) could be distributed in a form that was as easy to build as a Hello, World program.

I don't think I claimed that they were perfect, finished products.

(But it seems I may have overestimated people's ability to compile a 'naked' hello.c file, without a configuration script and makefile to do the work...)

--
bartc
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to