[Insight-developers] Longstanding warnings in ThirdParty/MetaIO/src/MetaIO

Williams, Norman K norman-k-williams at uiowa.edu
Thu Aug 25 15:34:57 EDT 2011


No one has changed this code in some time.


I got rid of tabs and trailing white space on July 6.

The compiler's complaint appears to be bogus.  The code is clumsy-looking
but it appears to be correct.

_mf->value is (as the warning states of type double[4096],

What's happening on the statement throwing the warning is that it's
putting a zero in the last byte of _mf->value:

        ((char *)(_mf->value))[(sizeof(_mf->value)-1)] = '\0';

I don't build with CLang but someone who does should try this and see if
it makes CLang stop complaining for no good reason.

        *(static_cast<char *>(_mf->value) + sizeof(_mf->value) - 1) = '\0';

One might complain about the idea of using an array of double as a string
buffer, but the fact is that no one is funded to re-write MetaIO right
now.  There are dozens of ways in which MetaIO could be re-written to be
closer to modern ideals for Software Engineering & C++. The existing code
works, though.

On 8/25/11 2:10 PM, "Sean McBride" <sean at rogue-research.com> wrote:

>Hi all,
>
>For several days now, both my ITK and VTK dashboards have this warning.
>I think whoever changed this code has not noticed the new warnings:
>
><http://www.cdash.org/CDash/viewBuildError.php?type=1&buildid=1464266>
><http://www.cdash.org/CDash/viewBuildError.php?type=1&buildid=1463568>
>
>In file included from
>/Users/builder/kitware/ITK/Modules/ThirdParty/MetaIO/src/MetaIO/metaArrow.
>cxx:12:
>In file included from
>/Users/builder/kitware/ITK/Modules/ThirdParty/MetaIO/src/MetaIO/metaArrow.
>h:17:
>/Users/builder/kitware/ITK/Modules/ThirdParty/MetaIO/src/MetaIO/metaUtils.
>h:379:15: warning: array index of '32767' indexes past the end of an
>array (that contains 4096 elements) [-Warray-bounds]
>    ((char *)(_mf->value))[(sizeof(_mf->value)-1)] = '\0';
>              ^             ~~~~~~~~~~~~~~~~~~~~
>
>/Users/builder/kitware/ITK/Modules/ThirdParty/MetaIO/src/MetaIO/metaArrow.
>cxx:199:3: note: in instantiation of function template specialization
>'MET_InitWriteField<double>' requested here
>  MET_InitWriteField(mF, "Direction", MET_DOUBLE_ARRAY, m_NDims,
>M_Direction);
>  ^
>
>/Users/builder/kitware/ITK/Modules/ThirdParty/MetaIO/src/MetaIO/metaTypes.
>h:201:4: note: array 'value' declared here
>   double         value[4096]; // Memory and pointers for the field's
>value(s).
>   ^
>1 warning generated.
>
>Cheers,
>
>--
>____________________________________________________________
>Sean McBride, B. Eng                 sean at rogue-research.com
>Rogue Research                        www.rogue-research.com
>Mac Software Developer              Montréal, Québec, Canada
>
>
>_______________________________________________
>Powered by www.kitware.com
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Kitware offers ITK Training Courses, for more information visit:
>http://kitware.com/products/protraining.html
>
>Please keep messages on-topic and check the ITK FAQ at:
>http://www.itk.org/Wiki/ITK_FAQ
>
>Follow this link to subscribe/unsubscribe:
>http://www.itk.org/mailman/listinfo/insight-developers



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________


More information about the Insight-developers mailing list