Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

long double trouble with gcc 4.0

I have recently upgraded to Xcode 2.2.1 from 2.0. Suddenly, reliable C code (a simulation model), that uses lots of long doubles, has started producing unusual output.

The model tracks frequencies stored in arrays of long doubles. I first noticed that frequecies that should be 1 are 2, which should be impossible. On closer inspection, many of the other numbers are not what I would expect, while some are what I would expect.

I have determined that this is a gcc 4.0 specific problem. Compiling with 3.3 or 2.95 (on various G4 and G5 PPC machines) gets rid of the problem.

It may be just the output that is messed up, as part of the simulation still reach its stopping point (based on the frequencies) in the same number of generations. Also, when I check values in the debugger, they seem fine. I am printing with printf and fprintf statements using %Le format .

Any ideas what is going on?

iMacG5 and PowerMacG5 PPC machines, Mac OS X (10.4.6), Xcode 2.2.1

Posted on May 18, 2006 6:01 PM

Reply
Question marked as Best reply

Posted on May 18, 2006 6:20 PM

Are you passing -Wall to catch printf and variable-assignment mismatches and miscasts? Is there any C++ code in your thing or anything you link against?
8 replies

May 19, 2006 6:42 AM in response to Dale Ranta

At appears that long double is 128 bytes on gcc 4.0,
I had to add the CFLAGS "-mlong-double-64" to get
some of my programs working.



Correct me if I am wrong, but no matter what the length of the variable in memory, %Le should deal with it properly. Converting it back to a 64 bit number is a workaround that is equivalent to compiling it with gcc 3.3, which I am doing for the time being. Part of my reason for switching to gcc 4.0 was to get the greater precision of the longer double.

Should I report this as a bug to either apple or to gcc?

May 19, 2006 8:11 AM in response to pat_lorch

If you can identify it as a bug in gcc, you should check on "http://gcc.gnu.org/bugzilla" and if nobody else has reported the problem - file a bug report. With GFORTRAN 128 bit doubles have many errors and mostly do not work on the PowerPC, the problems are known and they are working on it. gcc on the PowerPC may also sometimes choke on long double.

long double trouble with gcc 4.0

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.