<font size="2">
<p>Hi all,</p>
<p>I am asking that if you are rewriting or adding new code, please be aware of this issue as discussed below.</p>
<p>I have encountered a problem with Visual Studio 8 in relation to the issue of dereferencing an iterator.</p>
<p>Code like (vtkClientServerStream.cxx line 240)</p>
<p>memcpy(&*this->Internal->Data.end() - length, data, length); will break in debug mode using this compiler. You can get around it by doing something like:</p>
<p>memcpy(&*(--this->Internal->Data.end()) - length + 1, data, length); provided Data is not empty. </p>
<p>However I am uneasy with this approach.</p>
<p>In the same file at line 1205:</p>
<p>unsigned char* end = &*this->Internal->Data.end(); Will also always break with the VC 8 compiler.</p>
<p>I have already filed a bug report for ParaView (2926) but I see that a similar issue has also cropped up with ITK.</p>
<p>We are not alone in this, one person here at work has also been caught by this one - they were dereferencing the end() marker to use it in a loop. I myself was caught by a similar problem dereferencing the iterator but not checking before I did it that it had reached end().
</p>
<p>My personal view is that I don't like things like that exemplified by " char* end = &*this->Internal->Data.end();" because there is an implicit assumption here that the notion of half-open intervals in the STL is being circumvented by this approach.
</p>
<p>I apologize if this sounds autocratic, but I am trying to save us all lot of grief in the future! I suspect other compilers will follow suit.</p>
<p>If anyone wants to contribute to a discussion as to what the best approach should be please do.</p>
<p>Also please be aware that there is a bug in the compiler regarding <sstream>; Namely stringstream or istringstream fail to read comma separated lists of integers. </p>
<p class="MsoNormal"><font face="Arial" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">See: <a title="http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=275546dc-710d-4503-bbf6-21d1dad15e36" href="http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=275546dc-710d-4503-bbf6-21d1dad15e36">
<font color="#0000ff">http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=275546dc-710d-4503-bbf6-21d1dad15e36</font></a></span></font></p>
<p class="MsoNormal"><font face="Arial" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">And: <a title="http://www.codecomments.com/archive371-2006-1-778318.html" href="http://www.codecomments.com/archive371-2006-1-778318.html">
<font color="#0000ff">http://www.codecomments.com/archive371-2006-1-778318.html</font></a> for more discussion. I don't recommend patching the STL! It is a deeper issue than just the locale problem.</span></font></p>
<p class="MsoNormal"><font face="Arial" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Note that setting the codepage only works for the first integer being read.</span></font></p>
<p class="MsoNormal"><font face="Arial" color="navy" size="2"><span style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">My fix works better but it means that the input stream has to be modified.</span></font></p>
<p>Andrew</p></font><br clear="all"><br>-- <br><br>___________________________________________<br>Andrew J. P. Maclean<br>Centre for Autonomous Systems<br>The Rose Street Building J04<br>The University of Sydney 2006 NSW
<br>AUSTRALIA<br>Ph: +61 2 9351 3283<br>Fax: +61 2 9351 7474<br>URL: <a href="http://www.cas.edu.au/">http://www.cas.edu.au/</a><br>___________________________________________<br>