This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: single to double conversion


On Sep 27, 2006, at 12:35 PM, Steve Kargl wrote:

The author of g77 made the decide to use the f2c runtime library.
f2c always promotes a single precision function to double
precision.

I don't see an obvious way to do that and still conform to the Fortran standard. Perhaps I am missing a trick. Or perhaps g77 just fails to conform to the Fortran standard there. Having a compiler switch to enable a nonconforming behavior is one thing. But having a compiler that did not even have the option to conform to the standard strikes me as.... um.... problematic.


The nonconformance might not show up in most codes, but it sure isn't hard to come up with a case of valid Fortran code that would fail under such an implementation. Consider

call sub(f(x))

where f(x) returns a (single precision) real, and sub has a (single precision) real dummy argument. If f(x) is implemented to return a double instead of a single, then its result isn't going to be valid as an actual argument for sub. But if sub is separately compiled, there won't be an opportunity for the compiler to detect or fix the problem.

Perhaps I'm misunderstanding what was going on here, but I'm at least a little suspicious that you've just described a way in which g77 violates the standard (which is different from extending it).

--
Richard Maine                |  Good judgment comes from experience;
Richard.Maine@nasa.gov       |  experience comes from bad judgment.
                            |        -- Mark Twain


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]