HP aC++/C Compiler Incompatibility?

This is a discussion on HP aC++/C Compiler Incompatibility? within the C Programming forums, part of the General Programming Boards category; Hello all, I am currently working on a debugging project. We have a C program that, long story short, takes ...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Location
    Middletown, PA
    Posts
    9

    Question HP aC++/C Compiler Incompatibility?

    Hello all,

    I am currently working on a debugging project. We have a C program that, long story short, takes some financial figures, performs some arithmetic on them, and outputs them into another file.

    This program worked perfectly for years. However, after a recent HP Server upgrade to a box running an Itanium(R) processor and a software upgrade to the HP-UX B.11.23 U ia64 operating system, some of the values being printed out were being "pushed" to the right by one place and zeroes added on the left, while the values that were originally at the farthest to the right were being truncated. (i.e. 123456 became 012345)

    This only occurs when the C source code is compiled on the new machine (using the HP aC++/C A.05.50 compiler). The old executables (which were compiled previously on the old hardware and software) still work perfectly.

    Any ideas you may have will be very helpful. This has stumped us since March.

    Thanks!

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    Well, I can only assume you did something in the code that's undefined according to the standard or some mistake.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Or your code possibly assumed something about the platform that you were compiling for that is untrue of the new server.

  4. #4
    Registered User
    Join Date
    Jul 2008
    Location
    Middletown, PA
    Posts
    9
    Well that's the confusing part...there were no mistakes in the code before, and no changes were made to it. The change in either the compiler or in the hardware or operating system is what I'm thinking caused the problem.

    But what's interesting is that the binaries we compiled before still run perfectly, and correctly, on the new hardware - so I'm led to believe the problem lies in the compilation. Though I'm not sure how/why that would change anything.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    Are you sure there are no problems with the code?
    Remember that just because happens to run, doesn't mean it's right.
    There can be factors in the code that relies on knowledge that the types are of a typical length and such.
    I doubt very much it's the compiler.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Well, that is an indication that Elysia and/or I are/am correct about our assessment. Your code is most likely making assumptions that are invalid in certain circumstances.

  7. #7
    Registered User
    Join Date
    Jul 2008
    Location
    Middletown, PA
    Posts
    9

    Compilers

    Well, what you're saying is entirely true - I didn't write the code myself, so I don't know what all it assumes. I can tell you that the vast majority of the data types are doubles and chars, though. I was hoping that it would be perhaps an option that needed to be set with the new compiler or something like that, because I really don't want to wade through 40 pages of code I didn't write looking for someone else's mistake...that's never fun.

    But still, I have to re-emphasize that I find it very interesting that the executables compiled with the old compiler still run fine on the new hardware. It's just something different with the way the new compiler handles data types, I'm guessing.

    Thanks for your thoughts, though!
    Last edited by ShearWater509; 07-08-2008 at 11:55 AM.

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    Find a few printf() statements which produce different results.

    Generate short test programs which invoke examples of those printf() statements, with some meaningful data.

    Compile with the old and new compilers, and check results.
    If you find one which produces different results, post the code here and we'll tell you what's wrong with it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Registered User
    Join Date
    Jul 2008
    Location
    Middletown, PA
    Posts
    9

    I'm Afraid I Can't

    I'm afraid I can't use printf statements. I mean, I can print out values in the code I'm working, but can't print out corresponding values in the version of the program that works, because it is in executable format and I have no way of recompiling it without introducing whatever these new errors are in the new compiler.

    The more and more I run though this code, the more I'm sure there's a compiler incompatibility, the code is consistent and correct.

  10. #10
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    At least you can add printf()'s in the code and recompile it. Yes, it'll be wrong, but you'll get to see where it goes wrong, thus possibly leading you to a solution. If you can run the old one with a debugger, you can compare the values of variables to what the new one prints out.

    I find it hard to believe the code is consistent and correct and the compiler is broken. The compiler came with this system, and you would be having us believe that your vendors gave you a broken compiler. Perhaps that is the case, but I just think it doesn't make sense to throw up your hands and blame the system before you examine yourself thoroughly.

  11. #11
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by ShearWater509 View Post
    I'm afraid I can't use printf statements. I mean, I can print out values in the code I'm working, but can't print out corresponding values in the version of the program that works, because it is in executable format and I have no way of recompiling it without introducing whatever these new errors are in the new compiler.

    The more and more I run though this code, the more I'm sure there's a compiler incompatibility, the code is consistent and correct.
    Again, the likelihood that valid, correct code produces different output on different compiler, which both conform to ANSI standard is very slim.
    Of course the old executable still runs fine, you didn't recompile anything, but that doesn't mean it's due to the compiler or the libraries. Like everyone here said, it's most likely your code doing something that assumes a certain architecture.
    Surely there must some way for you to get access to one of the old servers to compile those test programs?

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  12. #12
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    The question was.
    Do you have access to both compilers?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  13. #13
    Registered User
    Join Date
    Jul 2008
    Location
    Middletown, PA
    Posts
    9

    Compiler

    Sorry about that, I didn't mean to set off anyone's nerves, and I apologize if I did. Certainly not intended.

    Sadly no, I don't have access to the old compilers. I'm merely an intern at a huge corporation - I'm very small and they don't give me much to work with or very many resources...at all. I'm about ready to tell them I don't know what is wrong with this program...I'm getting very frustrated with it/staring at code for hours at a time...and I have other projects to do, too.

  14. #14
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,238
    I've dealt with quite a few proprietary UNIX vendors. While there may in fact be some standard-breaking behavior in your code, the vendor should be ensuring complete backward compatibility between releases. Report it as a bug to HP. If possible, provide them with source that demonstrates the issue.

    UNIX vendors will usually NOT respond by saying "change your broken code." For the most part they understand that big customers are unwilling to do that, and will work around the issue themselves. Having said that, if you do detect some standard-breaking behavior in your code, try to fix it.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  15. #15
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    http://www.gimpel.com/
    Run lint on the code, and see what it complains about.
    Actually, if you've never done this before, it will complain about a great many things.

    Before you baulk at the measly price of $240 for a single licence, add up the salaries of all the people involved with "This has stumped us since March.".

    For me, the only issue for the breakage is that someone managed to rely on some undefined or implementation defined behaviour of the old compiler. Was it even an ANSI-C compiler?

    Without tools such as lint, it's all too easy to wander off the true ANSI path, and just store up a whole bunch of problems for later.

    Or perhaps as a separate exercise, you might get GCC installed on the machine as well.
    gcc -W -Wall -ansi -pedantic -O2 prog.c
    will also spot a large number of suspicious things as well.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. C Compiler and stuff
    By pal1ndr0me in forum C Programming
    Replies: 10
    Last Post: 07-21-2006, 11:07 AM
  3. hp iPAQ 6300 && C compiler || C# compiler
    By xddxogm3 in forum Tech Board
    Replies: 2
    Last Post: 12-07-2004, 06:28 AM
  4. OpenScript2.0 Compiler
    By jverkoey in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2003, 12:52 PM
  5. Compiler Design... Anyone That Can Help!
    By ComputerNerd888 in forum C++ Programming
    Replies: 3
    Last Post: 09-27-2003, 09:48 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21