<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic AcdbWcs2Ucs overwrites memory in ObjectARX Forum</title>
    <link>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700038#M9224</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an example where acdbWcs2Ucs seems to overwrite memory:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;bool GetDwgViewExtents(AcGePoint2d &amp;amp;acadPtTL, AcGePoint2d &amp;amp;acadPtBR)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;// First retrieves the extents with GetWindowRect, ScreenToClient and acedCoordFromPixelToWorld into the following&lt;/P&gt;&lt;P&gt;acedDwgPoint dwgPtTL, dwgPtBR;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// I have tried using the acedDwgPoints directly, but the same happens, so this was an effort to try something else&lt;/P&gt;&lt;P&gt;AcGePoint2d acadPtTLorg, acadPtBRorg;&lt;BR /&gt;acadPtTLorg.set(dwgPtTL[0], dwgPtTL[1]);&lt;BR /&gt;acadPtBRorg.set(dwgPtBR[0], dwgPtBR[1]);&lt;BR /&gt;acdbWcs2Ucs(asDblArray(acadPtTLorg), asDblArray(acadPtTL), false); // acadPtTL correctly set to&amp;nbsp;{x=-15058.342090026275 y=1177968.0167071891 }&lt;BR /&gt;acdbWcs2Ucs(asDblArray(acadPtBRorg), asDblArray(acadPtBR), false); // acadPtBR correctyl set to&amp;nbsp;{x=-14905.579798326420 y=1177905.8325202183 }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// BUT: in the last call, acadPtTL[0] is unexpectedly&amp;nbsp;changed to 0.0!&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The really strange thing is, I added the following after this code, to compare in debug what happens:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ads_point tl, br;&lt;BR /&gt;tl[0] = dwgPtTL[0];&lt;BR /&gt;tl[1] = dwgPtTL[1];&lt;BR /&gt;br[0] = dwgPtBR[0];&lt;BR /&gt;br[1] = dwgPtBR[1];&lt;BR /&gt;acdbWcs2Ucs(tl, tl, false);&lt;BR /&gt;acdbWcs2Ucs(br, br, false);&lt;BR /&gt;acadPtTL.set(tl[0], tl[1]);&lt;BR /&gt;acadPtBR.set(br[0], br[1]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this code works just fine, but when compiling with this code there, also the first version suddenly works fine!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips on what is going on here are appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One concrete question is that the definition of asDblArray is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;inline double*&lt;BR /&gt;asDblArray(const AcGePoint2d&amp;amp; pnt)&lt;BR /&gt;{&lt;BR /&gt;return (double*)&amp;amp;pnt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where as far as I can tell, AcGePoint2d has no explicit conversion to a double *. It has some functions and only the 2 member variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;double x,y;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But is it really safe to assume that simply converting with a (double*) changes the pointer to an AcGePoint2d to a valid double[3] pointer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could this be the problem here, could it be a compiler error or am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Knut&lt;/P&gt;</description>
    <pubDate>Mon, 21 Nov 2016 14:57:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-11-21T14:57:25Z</dc:date>
    <item>
      <title>AcdbWcs2Ucs overwrites memory</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700038#M9224</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an example where acdbWcs2Ucs seems to overwrite memory:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;bool GetDwgViewExtents(AcGePoint2d &amp;amp;acadPtTL, AcGePoint2d &amp;amp;acadPtBR)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;// First retrieves the extents with GetWindowRect, ScreenToClient and acedCoordFromPixelToWorld into the following&lt;/P&gt;&lt;P&gt;acedDwgPoint dwgPtTL, dwgPtBR;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// I have tried using the acedDwgPoints directly, but the same happens, so this was an effort to try something else&lt;/P&gt;&lt;P&gt;AcGePoint2d acadPtTLorg, acadPtBRorg;&lt;BR /&gt;acadPtTLorg.set(dwgPtTL[0], dwgPtTL[1]);&lt;BR /&gt;acadPtBRorg.set(dwgPtBR[0], dwgPtBR[1]);&lt;BR /&gt;acdbWcs2Ucs(asDblArray(acadPtTLorg), asDblArray(acadPtTL), false); // acadPtTL correctly set to&amp;nbsp;{x=-15058.342090026275 y=1177968.0167071891 }&lt;BR /&gt;acdbWcs2Ucs(asDblArray(acadPtBRorg), asDblArray(acadPtBR), false); // acadPtBR correctyl set to&amp;nbsp;{x=-14905.579798326420 y=1177905.8325202183 }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// BUT: in the last call, acadPtTL[0] is unexpectedly&amp;nbsp;changed to 0.0!&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The really strange thing is, I added the following after this code, to compare in debug what happens:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ads_point tl, br;&lt;BR /&gt;tl[0] = dwgPtTL[0];&lt;BR /&gt;tl[1] = dwgPtTL[1];&lt;BR /&gt;br[0] = dwgPtBR[0];&lt;BR /&gt;br[1] = dwgPtBR[1];&lt;BR /&gt;acdbWcs2Ucs(tl, tl, false);&lt;BR /&gt;acdbWcs2Ucs(br, br, false);&lt;BR /&gt;acadPtTL.set(tl[0], tl[1]);&lt;BR /&gt;acadPtBR.set(br[0], br[1]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this code works just fine, but when compiling with this code there, also the first version suddenly works fine!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips on what is going on here are appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One concrete question is that the definition of asDblArray is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;inline double*&lt;BR /&gt;asDblArray(const AcGePoint2d&amp;amp; pnt)&lt;BR /&gt;{&lt;BR /&gt;return (double*)&amp;amp;pnt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where as far as I can tell, AcGePoint2d has no explicit conversion to a double *. It has some functions and only the 2 member variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;double x,y;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But is it really safe to assume that simply converting with a (double*) changes the pointer to an AcGePoint2d to a valid double[3] pointer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could this be the problem here, could it be a compiler error or am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Knut&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 14:57:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700038#M9224</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-21T14:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: AcdbWcs2Ucs overwrites memory</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700065#M9225</link>
      <description>&lt;P&gt;Please use AcGePoint&lt;STRONG&gt;3&lt;/STRONG&gt;d instead of AcGePoint&lt;STRONG&gt;2&lt;/STRONG&gt;d&lt;/P&gt;
&lt;P&gt;acdbWcs2Ucs use double[&lt;STRONG&gt;3&lt;/STRONG&gt;] and not double[&lt;STRONG&gt;2&lt;/STRONG&gt;]. So it can overwrite you data.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 15:05:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700065#M9225</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-21T15:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: AcdbWcs2Ucs overwrites memory</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700072#M9226</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;... But is it really safe to assume that simply converting with a (double*) changes the pointer to an AcGePoint2d to a valid double[3] pointer?...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It is not safe!!!&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 15:07:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700072#M9226</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-21T15:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: AcdbWcs2Ucs overwrites memory</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700098#M9227</link>
      <description>&lt;P&gt;Thank you for a quick answer! I had just realized the exact same thing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;acdbWcs2Ucs expects double[3] pointers, while the (double*)AcGePoint2d obviously has only 2 doubles, so anything can happen when acdbWcs2Ucs writes the third double!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But as a prequel:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is the asDblArray safe if I _am_ using the result as a double[2]?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Knut&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 15:15:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700098#M9227</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-21T15:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: AcdbWcs2Ucs overwrites memory</title>
      <link>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700159#M9228</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But as a prequel:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is the asDblArray safe if I _am_ using the result as a double[2]?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes. In this situation asDblArray is safe.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2016 15:42:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/objectarx-forum/acdbwcs2ucs-overwrites-memory/m-p/6700159#M9228</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2016-11-21T15:42:10Z</dc:date>
    </item>
  </channel>
</rss>

