jaeandersson / swig

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.
http://www.swig.org
Other
23 stars 19 forks source link

Fix maybe-uninitialized pointer #73

Closed mwoehlke-kitware closed 8 years ago

mwoehlke-kitware commented 8 years ago

Explicitly initialize the SwigPtr in SWIG_Matlab_NewPointerObj to null. This fixes a -wmaybe-uninitialized warning, because the pointer may or may not be initialized by SWIG_Matlab_NewPointer, and is used later in the function.

jaeandersson commented 8 years ago

I'll accept this, since the commit is harmless and since it resolved the warning. But I don't think there can be any problems here since either swig_ptr is set or mexErrMsgIdAndTxt will terminate the execution.

mwoehlke-kitware commented 8 years ago

Thanks. I think the real problem is that mexErrMsgIdAndTxt isn't marked [[noreturn]], so the compiler has no way of knowing that it will terminate execution... which makes life not so fun for anyone using -Werror, as we are.

jaeandersson commented 8 years ago

I see, that makes sense. Thanks for fixing this!