Steve Dower <steve.do...@python.org> added the comment:

Unfortunately, this isn't really a safe cast, as we're going from void to 
non-void return value.

On x86 with current calling conventions, this is okay, since the return value 
is in a register that does not change or require cleanup by the caller. 
However, I wouldn't want to assume that all future calling conventions on other 
architectures would also permit this - returning a pointer value on the stack 
or in some way that requires cleanup is entirely possible, and is the sort of 
problem that would likely only be detectable by this warning or very careful 
memory measurements (or possibly a very confusing crash due to invalid stack 
modifications). 

It's also possible that returning an invalid pointer could cause a compiler to 
one day invoke its undefined behavior clause. Even though *we* don't use the 
return value, it still gets returned somewhere.

I'm not thrilled about the memory allocation here either, but there isn't 
really much of an option in my opinion.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33015>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to