Pelles C forum

Pelles C => General discussions => Topic started by: aronoffs on October 25, 2009, 01:06:13 AM

Title: Printing some integers causes strange numbers on rpt unless printf done first!
Post by: aronoffs on October 25, 2009, 01:06:13 AM
Hello,

I developed a financial calculator for my own use which does numerous calcs, then creates a spreadsheet-like report.  The amounts that print come from global arrays of integers.  I've had this program working for 5 years.

I recently upgraded to version 6 of Pelles C and also made a few tweaks to the program.  Now the report is showing a few of the columns with incorrect,  very large numbers, nothing like what should have been calculated. 

Since my logic seemed correct, I decided to display values that make up the calculations for these bad columns of data.  These displays showed that all variables that make up the calculations and the integers that receive the values to print all look fine.  Not only that, the report now shows the values for these columns correctly!!  No more strange, large numbers.

Further testing has shown that the numbers appear correctly on the report ONLY IF these display's are in the program.

Anybody with ideas on this?

Thanks.
Title: Re: Printing some integers causes strange numbers on rpt unless printf done first!
Post by: frankie on October 26, 2009, 08:10:49 AM
What happen if you compile your original program with optimizations turned off? Is result Ok?
Try also to add the specifier "volatile" to the variables that carry wrong values.
I.e.
  int a; -> volatile int a;
If these two options, on the original software without printouts, give you good result maybe there is a bug in compiler optimizations. In this case please try to isolate the smallest piece of software that exhibits the problem and post it in bug reports section. This will help Pelle, when he will be back, to diagnose the compiler.