<?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 Re: Run time error with cc -O optimization on in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786810#M720455</link>
    <description>Thank you for all the replies.  I called my HP rep and installed the latest C compiler but still got the error.  When I did (sort of) what Martin suggested and explicitly declared my loop indeces as "unsigned int", the error magically went away. Thanks again.</description>
    <pubDate>Mon, 19 Aug 2002 19:42:20 GMT</pubDate>
    <dc:creator>Gus Larsson</dc:creator>
    <dc:date>2002-08-19T19:42:20Z</dc:date>
    <item>
      <title>Run time error with cc -O optimization on</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786802#M720447</link>
      <description>Hello,&lt;BR /&gt;I am getting a weird run-time condition that occurs when I use the cc  "-O" optimization but not when I use no optimization. Here is the code in question:&lt;BR /&gt;         j = 0;&lt;BR /&gt;         while ((j &amp;lt; num) &amp;amp;&amp;amp; (i != ids[j])) {&lt;BR /&gt;            printf ("\nWe shouldnt be here if theyre equal!");&lt;BR /&gt;            j++;&lt;BR /&gt;         }&lt;BR /&gt;j and num are both local integers, and num is set to the result of a function call several lines earlier. In the test we were running, num happens to be zero.  However, the inside of the while-loop is executed if the "-O" optimization is used! This doesn't happen when no optimization is used.  &lt;BR /&gt;&lt;BR /&gt;I browsed the patch list but didn't see any relating specifically to this problem.  Is there a particular patch that I should use? I am running on HP-UX 11.0 on a J5600, and "what /usr/bin/cc" gives this:&lt;BR /&gt;/usr/bin/cc:&lt;BR /&gt;         LINT A.11.01.20 CXREF A.11.01.20&lt;BR /&gt;        HP92453-01 A.11.01.20 HP C Compiler&lt;BR /&gt;         $ CUPI80_IC7  Jan  7 1999 11:20:34 $ &lt;BR /&gt;&lt;BR /&gt;Thanks for any info,&lt;BR /&gt;&lt;BR /&gt;Gus Larsson</description>
      <pubDate>Thu, 15 Aug 2002 11:37:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786802#M720447</guid>
      <dc:creator>Gus Larsson</dc:creator>
      <dc:date>2002-08-15T11:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Run time error with cc -O optimization on</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786803#M720448</link>
      <description>a5:/ 101 # swlist -l product | grep ANSI&lt;BR /&gt;  C-ANSI-C              B.11.11.04     HP C/ANSI C Compiler&lt;BR /&gt;  PHSS_25985            1.0            ANSI C compiler General patch&lt;BR /&gt;a5:/ 102 #&lt;BR /&gt;</description>
      <pubDate>Thu, 15 Aug 2002 11:46:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786803#M720448</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-08-15T11:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Run time error with cc -O optimization on</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786804#M720449</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I advise you to upgrade to a newer&lt;BR /&gt;version of the compiler.&lt;BR /&gt;I have seen similar problems solved&lt;BR /&gt;by upgrading the compiler.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Olav</description>
      <pubDate>Thu, 15 Aug 2002 11:53:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786804#M720449</guid>
      <dc:creator>Olav Baadsvik</dc:creator>
      <dc:date>2002-08-15T11:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Run time error with cc -O optimization on</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786805#M720450</link>
      <description>Hi,  I feel both those answers are on the right track, but applying patches so far this morning has not helped.  Here is what I get now for "what /usr/bin/cc":             &lt;BR /&gt;/usr/bin/cc:&lt;BR /&gt;         LINT A.11.01.25171.GP CXREF A.11.01.25171.GP&lt;BR /&gt;        HP92453-01 A.11.01.25171.GP HP C Compiler&lt;BR /&gt;         $   Sep  8 2000 23:13:51 $ &lt;BR /&gt;&lt;BR /&gt;And typing "swlist -l product | grep ANSI" gives this:&lt;BR /&gt;&lt;BR /&gt;  C-ANSI-C              B.11.01.20     HP C/ANSI C Compiler &lt;BR /&gt;  PHSS_25171            1.0            ANSI C compiler cumulative patch &lt;BR /&gt;&lt;BR /&gt;I still get the error when I compile my code with the default "-O" optimization. The only patches I have been able to apply were PHSS_25171 and PHSS_25249; trying to apply other promising patches failed because I apparently didn't have the right base file sets. Whatever.&lt;BR /&gt;Thanks for any help,&lt;BR /&gt;Gus</description>
      <pubDate>Thu, 15 Aug 2002 16:24:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786805#M720450</guid>
      <dc:creator>Gus Larsson</dc:creator>
      <dc:date>2002-08-15T16:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Run time error with cc -O optimization on</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786806#M720451</link>
      <description>Gus, &lt;BR /&gt;&lt;BR /&gt;I think this is a pretty common phenomenon. With some compilers, optimization is documented to give unpredictable results in some cases, and in numerous cases, we haven't had any other chance but disable optimization for selected source files. &lt;BR /&gt;&lt;BR /&gt;In many cases, the fact that an error disappears when compiling non-optimized is a side effect of the now different memory layout, but in more cases than not, we gave up on trying to find the cause for the error, and just switched off optimization for the source file. &lt;BR /&gt;&lt;BR /&gt;Regards, &lt;BR /&gt;&lt;BR /&gt;Martin</description>
      <pubDate>Fri, 16 Aug 2002 07:31:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786806#M720451</guid>
      <dc:creator>Martin Schneider_2</dc:creator>
      <dc:date>2002-08-16T07:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: Run time error with cc -O optimization on</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786807#M720452</link>
      <description>&lt;BR /&gt;This could also have to do with signedness of variables. Try declaring all variables involved (num, i, j) as either signed or unsigned. Comparing a signed to an unsigned var can give the wrong answer if the sign bit is on and gets counted as a power of two.</description>
      <pubDate>Fri, 16 Aug 2002 07:46:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786807#M720452</guid>
      <dc:creator>Martin Schneider_2</dc:creator>
      <dc:date>2002-08-16T07:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Run time error with cc -O optimization on</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786808#M720453</link>
      <description>You're still on an old C compiler version. Do you have recent "Application" CD's? Can you order them on SUM, or request them from your HP representative?</description>
      <pubDate>Fri, 16 Aug 2002 07:57:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786808#M720453</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-08-16T07:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Run time error with cc -O optimization on</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786809#M720454</link>
      <description>add the latest libc patch</description>
      <pubDate>Fri, 16 Aug 2002 10:19:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786809#M720454</guid>
      <dc:creator>Judy Traynor</dc:creator>
      <dc:date>2002-08-16T10:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Run time error with cc -O optimization on</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786810#M720455</link>
      <description>Thank you for all the replies.  I called my HP rep and installed the latest C compiler but still got the error.  When I did (sort of) what Martin suggested and explicitly declared my loop indeces as "unsigned int", the error magically went away. Thanks again.</description>
      <pubDate>Mon, 19 Aug 2002 19:42:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/run-time-error-with-cc-o-optimization-on/m-p/2786810#M720455</guid>
      <dc:creator>Gus Larsson</dc:creator>
      <dc:date>2002-08-19T19:42:20Z</dc:date>
    </item>
  </channel>
</rss>

