- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Run time error with cc -O optimization on
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 04:37 AM
тАО08-15-2002 04:37 AM
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:
j = 0;
while ((j < num) && (i != ids[j])) {
printf ("\nWe shouldnt be here if theyre equal!");
j++;
}
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.
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:
/usr/bin/cc:
LINT A.11.01.20 CXREF A.11.01.20
HP92453-01 A.11.01.20 HP C Compiler
$ CUPI80_IC7 Jan 7 1999 11:20:34 $
Thanks for any info,
Gus Larsson
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 04:46 AM
тАО08-15-2002 04:46 AM
Re: Run time error with cc -O optimization on
C-ANSI-C B.11.11.04 HP C/ANSI C Compiler
PHSS_25985 1.0 ANSI C compiler General patch
a5:/ 102 #
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 04:53 AM
тАО08-15-2002 04:53 AM
Re: Run time error with cc -O optimization on
I advise you to upgrade to a newer
version of the compiler.
I have seen similar problems solved
by upgrading the compiler.
Regards
Olav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-15-2002 09:24 AM
тАО08-15-2002 09:24 AM
Re: Run time error with cc -O optimization on
/usr/bin/cc:
LINT A.11.01.25171.GP CXREF A.11.01.25171.GP
HP92453-01 A.11.01.25171.GP HP C Compiler
$ Sep 8 2000 23:13:51 $
And typing "swlist -l product | grep ANSI" gives this:
C-ANSI-C B.11.01.20 HP C/ANSI C Compiler
PHSS_25171 1.0 ANSI C compiler cumulative patch
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.
Thanks for any help,
Gus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2002 12:31 AM
тАО08-16-2002 12:31 AM
Re: Run time error with cc -O optimization on
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.
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.
Regards,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2002 12:46 AM
тАО08-16-2002 12:46 AM
SolutionThis 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2002 12:57 AM
тАО08-16-2002 12:57 AM
Re: Run time error with cc -O optimization on
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-16-2002 03:19 AM
тАО08-16-2002 03:19 AM
Re: Run time error with cc -O optimization on
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-19-2002 12:42 PM
тАО08-19-2002 12:42 PM