Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6566725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:15:00+00:00 2026-05-25T14:15:00+00:00

I have a C program giving different results when run on two machines. On

  • 0

I have a C program giving different results when run on two machines.

On the first machine (Linux Ubuntu, gcc compiler v 4.4.3, 64bit, 4GB memory) it seems to work fine and gives reasonable results (actually this is the machine on which it has been mainly developed).

On the second machine (Mac OSX 10.5.8, gcc compiler v 4.4.5, 32bit, 2GB memory) the results appear to be nonsense.

In particular, there is an array A filled in during a FOR cycle in which each term A[i] depends on A[i-1]. I have found out that after about 4000 steps my machine starts to forget the A[i-1] values and then calculates nonsense.

Even more bizarre to me, the problem disappears if in the initial list of variable declaration of the function I add another fictitious array, which I don’t even use in the program.

That is, a code with a header like

...
double X[n_max];           
double Y[n_max]; 
double A[n_max]; 
...

works, while

...
double X[n_max];           
// double Y[n_max]; 
double A[n_max]; 

does not.

I guess there is some sort of problem in memory allocation, and that when I allocate memory for the fictitious array Y the mess is simply moved elsewhere.

I don’t understand neither why my Mac seems to have no problems in overwriting data it is supposed to remember, nor why the same program is working on the Linux machine.

I hope that the problem is clear, any help is appreciated.
Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:15:01+00:00Added an answer on May 25, 2026 at 2:15 pm

    Well, it is obvious that one of the X[] or A[] arrays is being indexed out of bounds. Just as a test replace all array indices by unsigned or size_t, recompile and run under a debugger. The program will probably segfault.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program 'foo' running different threads, fooT1, fooT2, .. fooTn. Now if
I have a C++ program that is giving this error as soon as the
I have a program which works fine under VC++, but is giving me an
I can not compile, this program is giving me errors. I have already spend
I have written a simple program where to read the first 4 characters and
I have downloaded the java JDK but I am unable to run the program.
I have program that has a variable that should never change. However, somehow, it
I have program, that must interact with a console program before my program can
I have program that runs fast enough. I want to see the number of
I have a program that spits out both standard error and standard out, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.