[Python-Dev] Compiler warnings

Scott Dial scott+python-dev at scottdial.com
Wed Feb 1 14:07:00 CET 2006

Thomas Wouters wrote:
> My main problem with fixing the warnings is that I don't see the difference
> between, for example, the 'ssize' variable and the 'nchannels' variable

As was pointed out elsewhere, any variable that is passed by-reference 
to another function is ignored for the purposes of these warnings. The 
fact that the ioctl call with nchannels happens well after potential 
problem spots doesn't matter. It appears that GCC has eliminated it from 
the decision process for the purposes of these warnings already.

The problem roots from the ambiguity of the returns. At compile-time, 
there is no way for GCC that the return value will be negative in the 
error case, and thus the return may cause us to go down an execution 
path that ssize (and nchannels) need to be initialized. This check seems 
to be very shallow, even if you provide a guarantee that the return 
value will be well-behaved, GCC has already given up on figuring this 
out. The rule of thumb here seems to be "if you make a call to a 
function which provides the condition for the uninitialized variable is 
used, then the condition is decided to be ambiguous."

So, either the GCC people have not noticed this problem, or (more 
likely) have decided that this is acceptable, but clearly it will cause 
spurious warnings. Hey, after all, they are just warnings.

Scott Dial
scott at scottdial.com
dialsa at rose-hulman.edu

More information about the Python-Dev mailing list