home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / UNIX / GNU / gcc-2.7.2.3.1-I / info / g77.info-17 < prev    next >
Encoding:
GNU Info File  |  1997-09-12  |  39.8 KB  |  969 lines

  1. This is Info file g77.info, produced by Makeinfo version 1.68 from the
  2. input file g77.texi.
  3.  
  4.    This file explains how to use the GNU Fortran system.
  5.  
  6.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  7. Boston, MA 02111-1307 USA
  8.  
  9.    Copyright (C) 1995-1997 Free Software Foundation, Inc.
  10.  
  11.    Permission is granted to make and distribute verbatim copies of this
  12. manual provided the copyright notice and this permission notice are
  13. preserved on all copies.
  14.  
  15.    Permission is granted to copy and distribute modified versions of
  16. this manual under the conditions for verbatim copying, provided also
  17. that the sections entitled "GNU General Public License," "Funding for
  18. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  19. included exactly as in the original, and provided that the entire
  20. resulting derived work is distributed under the terms of a permission
  21. notice identical to this one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that the sections entitled "GNU General Public
  26. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  27. `Look And Feel'", and this permission notice, may be included in
  28. translations approved by the Free Software Foundation instead of in the
  29. original English.
  30.  
  31.    Contributed by James Craig Burley (<burley@gnu.ai.mit.edu>).
  32. Inspired by a first pass at translating `g77-0.5.16/f/DOC' that was
  33. contributed to Craig by David Ronis (<ronis@onsager.chem.mcgill.ca>).
  34.  
  35. INFO-DIR-SECTION Fortran Programming
  36. START-INFO-DIR-ENTRY
  37. * g77: (g77).               The GNU Fortran compilation system.
  38. END-INFO-DIR-ENTRY
  39.  
  40. 
  41. File: g77.info,  Node: Floating-point Exception Handling,  Next: Nonportable Conversions,  Prev: POSIX Standard,  Up: Missing Features
  42.  
  43. Floating-point Exception Handling
  44. ---------------------------------
  45.  
  46.    The `gcc' backend and, consequently, `g77', currently provides no
  47. control over whether or not floating-point exceptions are trapped or
  48. ignored.  (Ignoring them typically results in NaN values being
  49. propagated in systems that conform to IEEE 754.)  The behaviour is
  50. inherited from the system-dependent startup code.
  51.  
  52.    Most systems provide some C-callable mechanism to change this; this
  53. can be invoked at startup using `gcc''s `constructor' attribute.  For
  54. example, just compiling and linking the following C code with your
  55. program will turn on exception trapping for the "common" exceptions on
  56. an x86-based GNU system:
  57.  
  58.      #include <fpu_control.h>
  59.      void __attribute__ ((constructor))
  60.      trapfpe () {
  61.        (void) __setfpucw (_FPU_DEFAULT &
  62.                           ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM));
  63.      }
  64.  
  65. 
  66. File: g77.info,  Node: Nonportable Conversions,  Next: Large Automatic Arrays,  Prev: Floating-point Exception Handling,  Up: Missing Features
  67.  
  68. Nonportable Conversions
  69. -----------------------
  70.  
  71.    `g77' doesn't accept some particularly nonportable, silent data-type
  72. conversions such as `LOGICAL' to `REAL' (as in `A=.FALSE.', where `A'
  73. is type `REAL'), that other compilers might quietly accept.
  74.  
  75.    Some of these conversions are accepted by `g77' when the `-fugly'
  76. option is specified.  Perhaps it should accept more or all of them.
  77.  
  78. 
  79. File: g77.info,  Node: Large Automatic Arrays,  Next: Support for Threads,  Prev: Nonportable Conversions,  Up: Missing Features
  80.  
  81. Large Automatic Arrays
  82. ----------------------
  83.  
  84.    Currently, automatic arrays always are allocated on the stack.  For
  85. situations where the stack cannot be made large enough, `g77' should
  86. offer a compiler option that specifies allocation of automatic arrays
  87. in heap storage.
  88.  
  89. 
  90. File: g77.info,  Node: Support for Threads,  Next: Increasing Precision/Range,  Prev: Large Automatic Arrays,  Up: Missing Features
  91.  
  92. Support for Threads
  93. -------------------
  94.  
  95.    Neither the code produced by `g77' nor the `libf2c' library are
  96. thread-safe, nor does `g77' have support for parallel processing (other
  97. than the instruction-level parallelism available on some processors).
  98. A package such as PVM might help here.
  99.  
  100. 
  101. File: g77.info,  Node: Gracefully Handle Sensible Bad Code,  Next: Non-standard Conversions,  Prev: Increasing Precision/Range,  Up: Missing Features
  102.  
  103. Gracefully Handle Sensible Bad Code
  104. -----------------------------------
  105.  
  106.    `g77' generally should continue processing for warnings and
  107. recoverable (user) errors whenever possible--that is, it shouldn't
  108. gratuitously make bad or useless code.
  109.  
  110.    For example:
  111.  
  112.      INTRINSIC ZABS
  113.      CALL FOO(ZABS)
  114.      END
  115.  
  116. When compiling the above with `-ff2c-intrinsics-disable', `g77' should
  117. indeed complain about passing `ZABS', but it still should compile,
  118. instead of rejecting the entire `CALL' statement.  (Some of this is
  119. related to improving the compiler internals to improve how statements
  120. are analyzed.)
  121.  
  122. 
  123. File: g77.info,  Node: Non-standard Conversions,  Next: Non-standard Intrinsics,  Prev: Gracefully Handle Sensible Bad Code,  Up: Missing Features
  124.  
  125. Non-standard Conversions
  126. ------------------------
  127.  
  128.    `-Wconversion' and related should flag places where non-standard
  129. conversions are found.  Perhaps much of this would be part of `-Wugly*'.
  130.  
  131. 
  132. File: g77.info,  Node: Non-standard Intrinsics,  Next: Modifying DO Variable,  Prev: Non-standard Conversions,  Up: Missing Features
  133.  
  134. Non-standard Intrinsics
  135. -----------------------
  136.  
  137.    `g77' needs a new option, like `-Wintrinsics', to warn about use of
  138. non-standard intrinsics without explicit `INTRINSIC' statements for
  139. them.  This would help find code that might fail silently when ported
  140. to another compiler.
  141.  
  142. 
  143. File: g77.info,  Node: Modifying DO Variable,  Next: Better Pedantic Compilation,  Prev: Non-standard Intrinsics,  Up: Missing Features
  144.  
  145. Modifying `DO' Variable
  146. -----------------------
  147.  
  148.    `g77' should warn about modifying `DO' variables via `EQUIVALENCE'.
  149. (The internal information gathered to produce this warning might also
  150. be useful in setting the internal "doiter" flag for a variable or even
  151. array reference within a loop, since that might produce faster code
  152. someday.)
  153.  
  154.    For example, this code is invalid, so `g77' should warn about the
  155. invalid assignment to `NOTHER':
  156.  
  157.      EQUIVALENCE (I, NOTHER)
  158.      DO I = 1, 100
  159.         IF (I.EQ. 10) NOTHER = 20
  160.      END DO
  161.  
  162. 
  163. File: g77.info,  Node: Better Pedantic Compilation,  Next: Warn About Implicit Conversions,  Prev: Modifying DO Variable,  Up: Missing Features
  164.  
  165. Better Pedantic Compilation
  166. ---------------------------
  167.  
  168.    `g77' needs to support `-fpedantic' more thoroughly, and use it only
  169. to generate warnings instead of rejecting constructs outright.  Have it
  170. warn: if a variable that dimensions an array is not a dummy or placed
  171. explicitly in `COMMON' (F77 does not allow it to be placed in `COMMON'
  172. via `EQUIVALENCE'); if specification statements follow
  173. statement-function-definition statements; about all sorts of syntactic
  174. extensions.
  175.  
  176. 
  177. File: g77.info,  Node: Warn About Implicit Conversions,  Next: Invalid Use of Hollerith Constant,  Prev: Better Pedantic Compilation,  Up: Missing Features
  178.  
  179. Warn About Implicit Conversions
  180. -------------------------------
  181.  
  182.    `g77' needs a `-Wpromotions' option to warn if source code appears
  183. to expect automatic, silent, and somewhat dangerous compiler-assisted
  184. conversion of `REAL(KIND=1)' constants to `REAL(KIND=2)' based on
  185. context.
  186.  
  187.    For example, it would warn about cases like this:
  188.  
  189.      DOUBLE PRECISION FOO
  190.      PARAMETER (TZPHI = 9.435784839284958)
  191.      FOO = TZPHI * 3D0
  192.  
  193. 
  194. File: g77.info,  Node: Invalid Use of Hollerith Constant,  Next: Dummy Array Without Dimensioning Dummy,  Prev: Warn About Implicit Conversions,  Up: Missing Features
  195.  
  196. Invalid Use of Hollerith Constant
  197. ---------------------------------
  198.  
  199.    `g77' should disallow statements like `RETURN 2HAB', which are
  200. invalid in both source forms (unlike `RETURN (2HAB)', which probably
  201. still makes no sense but at least can be reliably parsed).  Fixed-form
  202. processing rejects it, but not free-form, except in a way that is a bit
  203. difficult to understand.
  204.  
  205. 
  206. File: g77.info,  Node: Dummy Array Without Dimensioning Dummy,  Next: Invalid FORMAT Specifiers,  Prev: Invalid Use of Hollerith Constant,  Up: Missing Features
  207.  
  208. Dummy Array Without Dimensioning Dummy
  209. --------------------------------------
  210.  
  211.    `g77' should complain when a list of dummy arguments containing an
  212. adjustable dummy array does not also contain every variable listed in
  213. the dimension list of the adjustable array.
  214.  
  215.    Currently, `g77' does complain about a variable that dimensions an
  216. array but doesn't appear in any dummy list or `COMMON' area, but this
  217. needs to be extended to catch cases where it doesn't appear in every
  218. dummy list that also lists any arrays it dimensions.
  219.  
  220.    For example, `g77' should warn about the entry point `ALT' below,
  221. since it includes `ARRAY' but not `ISIZE' in its list of arguments:
  222.  
  223.      SUBROUTINE PRIMARY(ARRAY, ISIZE)
  224.      REAL ARRAY(ISIZE)
  225.      ENTRY ALT(ARRAY)
  226.  
  227. 
  228. File: g77.info,  Node: Invalid FORMAT Specifiers,  Next: Ambiguous Dialects,  Prev: Dummy Array Without Dimensioning Dummy,  Up: Missing Features
  229.  
  230. Invalid FORMAT Specifiers
  231. -------------------------
  232.  
  233.    `g77' should check `FORMAT' specifiers for validity as it does
  234. `FORMAT' statements.
  235.  
  236.    For example, a diagnostic would be produced for:
  237.  
  238.      PRINT 'HI THERE!'  !User meant PRINT *, 'HI THERE!'
  239.  
  240. 
  241. File: g77.info,  Node: Ambiguous Dialects,  Next: Unused Labels,  Prev: Invalid FORMAT Specifiers,  Up: Missing Features
  242.  
  243. Ambiguous Dialects
  244. ------------------
  245.  
  246.    `g77' needs a set of options such as `-Wugly*', `-Wautomatic',
  247. `-Wvxt', `-Wf90', and so on.  These would warn about places in the
  248. user's source where ambiguities are found, helpful in resolving
  249. ambiguities in the program's dialect or dialects.
  250.  
  251. 
  252. File: g77.info,  Node: Unused Labels,  Next: Informational Messages,  Prev: Ambiguous Dialects,  Up: Missing Features
  253.  
  254. Unused Labels
  255. -------------
  256.  
  257.    `g77' should warn about unused labels when `-Wunused' is in effect.
  258.  
  259. 
  260. File: g77.info,  Node: Informational Messages,  Next: Uninitialized Variables at Run Time,  Prev: Unused Labels,  Up: Missing Features
  261.  
  262. Informational Messages
  263. ----------------------
  264.  
  265.    `g77' needs an option to suppress information messages (notes).
  266. `-w' does this but also suppresses warnings.  The default should be to
  267. suppress info messages.
  268.  
  269.    Perhaps info messages should simply be eliminated.
  270.  
  271. 
  272. File: g77.info,  Node: Uninitialized Variables at Run Time,  Next: Bounds Checking at Run Time,  Prev: Informational Messages,  Up: Missing Features
  273.  
  274. Uninitialized Variables at Run Time
  275. -----------------------------------
  276.  
  277.    `g77' needs an option to initialize everything (not otherwise
  278. explicitly initialized) to "weird" (machine-dependent) values, e.g.
  279. NaNs, bad (non-`NULL') pointers, and largest-magnitude integers, would
  280. help track down references to some kinds of uninitialized variables at
  281. run time.
  282.  
  283.    Note that use of the options `-O -Wuninitialized' can catch many
  284. such bugs at compile time.
  285.  
  286. 
  287. File: g77.info,  Node: Bounds Checking at Run Time,  Next: Labels Visible to Debugger,  Prev: Uninitialized Variables at Run Time,  Up: Missing Features
  288.  
  289. Bounds Checking at Run Time
  290. ---------------------------
  291.  
  292.    `g77' should offer run-time bounds-checking of array/subscript
  293. references in a fashion similar to `f2c'.
  294.  
  295.    Note that `g77' already warns about references to out-of-bounds
  296. elements of arrays when it detects these at compile time.
  297.  
  298. 
  299. File: g77.info,  Node: Labels Visible to Debugger,  Prev: Bounds Checking at Run Time,  Up: Missing Features
  300.  
  301. Labels Visible to Debugger
  302. --------------------------
  303.  
  304.    `g77' should output debugging information for statements labels, for
  305. use by debuggers that know how to support them.  Same with weirder
  306. things like construct names.  It is not yet known if any debug formats
  307. or debuggers support these.
  308.  
  309. 
  310. File: g77.info,  Node: Disappointments,  Next: Non-bugs,  Prev: Missing Features,  Up: Trouble
  311.  
  312. Disappointments and Misunderstandings
  313. =====================================
  314.  
  315.    These problems are perhaps regrettable, but we don't know any
  316. practical way around them for now.
  317.  
  318. * Menu:
  319.  
  320. * Mangling of Names::                       `SUBROUTINE FOO' is given
  321.                                               external name `foo_'.
  322. * Multiple Definitions of External Names::  No doing both `COMMON /FOO/'
  323.                                               and `SUBROUTINE FOO'.
  324. * Limitation on Implicit Declarations::     No `IMPLICIT CHARACTER*(*)'.
  325.  
  326. 
  327. File: g77.info,  Node: Mangling of Names,  Next: Multiple Definitions of External Names,  Up: Disappointments
  328.  
  329. Mangling of Names in Source Code
  330. --------------------------------
  331.  
  332.    The current external-interface design, which includes naming of
  333. external procedures, COMMON blocks, and the library interface, has
  334. various usability problems, including things like adding underscores
  335. where not really necessary (and preventing easier inter-language
  336. operability) and yet not providing complete namespace freedom for user
  337. C code linked with Fortran apps (due to the naming of functions in the
  338. library, among other things).
  339.  
  340.    Project GNU should at least get all this "right" for systems it
  341. fully controls, such as the Hurd, and provide defaults and options for
  342. compatibility with existing systems and interoperability with popular
  343. existing compilers.
  344.  
  345. 
  346. File: g77.info,  Node: Multiple Definitions of External Names,  Next: Limitation on Implicit Declarations,  Prev: Mangling of Names,  Up: Disappointments
  347.  
  348. Multiple Definitions of External Names
  349. --------------------------------------
  350.  
  351.    `g77' doesn't allow a common block and an external procedure or
  352. `BLOCK DATA' to have the same name.  Some systems allow this, but `g77'
  353. does not, to be compatible with `f2c'.
  354.  
  355.    `g77' could special-case the way it handles `BLOCK DATA', since it
  356. is not compatible with `f2c' in this particular area (necessarily,
  357. since `g77' offers an important feature here), but it is likely that
  358. such special-casing would be very annoying to people with programs that
  359. use `EXTERNAL FOO', with no other mention of `FOO' in the same program
  360. unit, to refer to external procedures, since the result would be that
  361. `g77' would treat these references as requests to force-load BLOCK DATA
  362. program units.
  363.  
  364.    In that case, if `g77' modified names of `BLOCK DATA' so they could
  365. have the same names as `COMMON', users would find that their programs
  366. wouldn't link because the `FOO' procedure didn't have its name
  367. translated the same way.
  368.  
  369.    (Strictly speaking, `g77' could emit a
  370. null-but-externally-satisfying definition of `FOO' with its name
  371. transformed as if it had been a `BLOCK DATA', but that probably invites
  372. more trouble than it's worth.)
  373.  
  374. 
  375. File: g77.info,  Node: Limitation on Implicit Declarations,  Prev: Multiple Definitions of External Names,  Up: Disappointments
  376.  
  377. Limitation on Implicit Declarations
  378. -----------------------------------
  379.  
  380.    `g77' disallows `IMPLICIT CHARACTER*(*)'.  This is not
  381. standard-conforming.
  382.  
  383. 
  384. File: g77.info,  Node: Non-bugs,  Next: Warnings and Errors,  Prev: Disappointments,  Up: Trouble
  385.  
  386. Certain Changes We Don't Want to Make
  387. =====================================
  388.  
  389.    This section lists changes that people frequently request, but which
  390. we do not make because we think GNU Fortran is better without them.
  391.  
  392. * Menu:
  393.  
  394. * Backslash in Constants::           Why `'\\'' is a constant that
  395.                                        is one, not two, characters long.
  396. * Initializing Before Specifying::   Why `DATA VAR/1/' can't precede
  397.                                        `COMMON VAR'.
  398. * Context-Sensitive Intrinsicness::  Why `CALL SQRT' won't work.
  399. * Context-Sensitive Constants::      Why `9.435784839284958' is a
  400.                                        single-precision constant,
  401.                                        and might be interpreted as
  402.                                        `9.435785' or similar.
  403. * Equivalence Versus Equality::      Why `.TRUE. .EQ. .TRUE.' won't work.
  404. * Order of Side Effects::            Why `J = IFUNC() - IFUNC()' might
  405.                                        not behave as expected.
  406.  
  407. 
  408. File: g77.info,  Node: Backslash in Constants,  Next: Initializing Before Specifying,  Up: Non-bugs
  409.  
  410. Backslash in Constants
  411. ----------------------
  412.  
  413.    In the opinion of many experienced Fortran users, `-fno-backslash'
  414. should be the default, not `-fbackslash', as currently set by `g77'.
  415.  
  416.    First of all, you can always specify `-fno-backslash' to turn off
  417. this processing.
  418.  
  419.    Despite not being within the spirit (though apparently within the
  420. letter) of the ANSI FORTRAN 77 standard, `g77' defaults to
  421. `-fbackslash' because that is what most UNIX `f77' commands default to,
  422. and apparently lots of code depends on this feature.
  423.  
  424.    This is a particularly troubling issue.  The use of a C construct in
  425. the midst of Fortran code is bad enough, worse when it makes existing
  426. Fortran programs stop working (as happens when programs written for
  427. non-UNIX systems are ported to UNIX systems with compilers that provide
  428. the `-fbackslash' feature as the default--sometimes with no option to
  429. turn it off).
  430.  
  431.    The author of GNU Fortran wished, for reasons of linguistic purity,
  432. to make `-fno-backslash' the default for GNU Fortran and thus require
  433. users of UNIX `f77' and `f2c' to specify `-fbackslash' to get the UNIX
  434. behavior.
  435.  
  436.    However, the realization that `g77' is intended as a replacement for
  437. *UNIX* `f77', caused the author to choose to make `g77' as compatible
  438. with `f77' as feasible, which meant making `-fbackslash' the default.
  439.  
  440.    The primary focus on compatibility is at the source-code level, and
  441. the question became "What will users expect a replacement for `f77' to
  442. do, by default?"  Although at least one UNIX `f77' does not provide
  443. `-fbackslash' as a default, it appears that the majority of them do,
  444. which suggests that the majority of code that is compiled by UNIX `f77'
  445. compilers expects `-fbackslash' to be the default.
  446.  
  447.    It is probably the case that more code exists that would *not* work
  448. with `-fbackslash' in force than code that requires it be in force.
  449.  
  450.    However, most of *that* code is not being compiled with `f77', and
  451. when it is, new build procedures (shell scripts, makefiles, and so on)
  452. must be set up anyway so that they work under UNIX.  That makes a much
  453. more natural and safe opportunity for non-UNIX users to adapt their
  454. build procedures for `g77''s default of `-fbackslash' than would exist
  455. for the majority of UNIX `f77' users who would have to modify existing,
  456. working build procedures to explicitly specify `-fbackslash' if that was
  457. not the default.
  458.  
  459.    One suggestion has been to configure the default for `-fbackslash'
  460. (and perhaps other options as well) based on the configuration of `g77'.
  461.  
  462.    This is technically quite straightforward, but will be avoided even
  463. in cases where not configuring defaults to be dependent on a particular
  464. configuration greatly inconveniences some users of legacy code.
  465.  
  466.    Many users appreciate the GNU compilers because they provide an
  467. environment that is uniform across machines.  These users would be
  468. inconvenienced if the compiler treated things like the format of the
  469. source code differently on certain machines.
  470.  
  471.    Occasionally users write programs intended only for a particular
  472. machine type.  On these occasions, the users would benefit if the GNU
  473. Fortran compiler were to support by default the same dialect as the
  474. other compilers on that machine.  But such applications are rare.  And
  475. users writing a program to run on more than one type of machine cannot
  476. possibly benefit from this kind of compatibility.  (This is consistent
  477. with the design goals for `gcc'.  To change them for `g77', you must
  478. first change them for `gcc'.  Do not ask the maintainers of `g77' to do
  479. this for you, or to disassociate `g77' from the widely understood, if
  480. not widely agreed-upon, goals for GNU compilers in general.)
  481.  
  482.    This is why GNU Fortran does and will treat backslashes in the same
  483. fashion on all types of machines (by default).  *Note Direction of
  484. Language Development::, for more information on this overall philosophy
  485. guiding the development of the GNU Fortran language.
  486.  
  487.    Of course, users strongly concerned about portability should indicate
  488. explicitly in their build procedures which options are expected by
  489. their source code, or write source code that has as few such
  490. expectations as possible.
  491.  
  492.    For example, avoid writing code that depends on backslash (`\')
  493. being interpreted either way in particular, such as by starting a
  494. program unit with:
  495.  
  496.      CHARACTER BACKSL
  497.      PARAMETER (BACKSL = '\\')
  498.  
  499. Then, use concatenation of `BACKSL' anyplace a backslash is desired.
  500. In this way, users can write programs which have the same meaning in
  501. many Fortran dialects.
  502.  
  503.    (However, this technique does not work for Hollerith constants--which
  504. is just as well, since the only generally portable uses for Hollerith
  505. constants are in places where character constants can and should be
  506. used instead, for readability.)
  507.  
  508. 
  509. File: g77.info,  Node: Initializing Before Specifying,  Next: Context-Sensitive Intrinsicness,  Prev: Backslash in Constants,  Up: Non-bugs
  510.  
  511. Initializing Before Specifying
  512. ------------------------------
  513.  
  514.    `g77' does not allow `DATA VAR/1/' to appear in the source code
  515. before `COMMON VAR', `DIMENSION VAR(10)', `INTEGER VAR', and so on.  In
  516. general, `g77' requires initialization of a variable or array to be
  517. specified *after* all other specifications of attributes (type, size,
  518. placement, and so on) of that variable or array are specified (though
  519. *confirmation* of data type is permitted).
  520.  
  521.    It is *possible* `g77' will someday allow all of this, even though
  522. it is not allowed by the FORTRAN 77 standard.
  523.  
  524.    Then again, maybe it is better to have `g77' always require
  525. placement of `DATA' so that it can possibly immediately write constants
  526. to the output file, thus saving time and space.
  527.  
  528.    That is, `DATA A/1000000*1/' should perhaps always be immediately
  529. writable to canonical assembler, unless it's already known to be in a
  530. `COMMON' area following as-yet-uninitialized stuff, and to do this it
  531. cannot be followed by `COMMON A'.
  532.  
  533. 
  534. File: g77.info,  Node: Context-Sensitive Intrinsicness,  Next: Context-Sensitive Constants,  Prev: Initializing Before Specifying,  Up: Non-bugs
  535.  
  536. Context-Sensitive Intrinsicness
  537. -------------------------------
  538.  
  539.    `g77' treats procedure references to *possible* intrinsic names as
  540. always enabling their intrinsic nature, regardless of whether the
  541. *form* of the reference is valid for that intrinsic.
  542.  
  543.    For example, `CALL SQRT' is interpreted by `g77' as an invalid
  544. reference to the `SQRT' intrinsic function, because the reference is a
  545. subroutine invocation.
  546.  
  547.    First, `g77' recognizes the statement `CALL SQRT' as a reference to
  548. a *procedure* named `SQRT', not to a *variable* with that name (as it
  549. would for a statement such as `V = SQRT').
  550.  
  551.    Next, `g77' establishes that, in the program unit being compiled,
  552. `SQRT' is an intrinsic--not a subroutine that happens to have the same
  553. name as an intrinsic (as would be the case if, for example, `EXTERNAL
  554. SQRT' was present).
  555.  
  556.    Finally, `g77' recognizes that the *form* of the reference is
  557. invalid for that particular intrinsic.  That is, it recognizes that it
  558. is invalid for an intrinsic *function*, such as `SQRT', to be invoked as
  559. a *subroutine*.
  560.  
  561.    At that point, `g77' issues a diagnostic.
  562.  
  563.    Some users claim that it is "obvious" that `CALL SQRT' references an
  564. external subroutine of their own, not an intrinsic function.
  565.  
  566.    However, `g77' knows about intrinsic subroutines, not just
  567. functions, and is able to support both having the same names, for
  568. example.
  569.  
  570.    As a result of this, `g77' rejects calls to intrinsics that are not
  571. subroutines, and function invocations of intrinsics that are not
  572. functions, just as it (and most compilers) rejects invocations of
  573. intrinsics with the wrong number (or types) of arguments.
  574.  
  575.    So, use the `EXTERNAL SQRT' statement in a program unit that calls a
  576. user-written subroutine named `SQRT'.
  577.  
  578. 
  579. File: g77.info,  Node: Context-Sensitive Constants,  Next: Equivalence Versus Equality,  Prev: Context-Sensitive Intrinsicness,  Up: Non-bugs
  580.  
  581. Context-Sensitive Constants
  582. ---------------------------
  583.  
  584.    `g77' does not use context to determine the types of constants or
  585. named constants (`PARAMETER'), except for (non-standard) typeless
  586. constants such as `'123'O'.
  587.  
  588.    For example, consider the following statement:
  589.  
  590.      PRINT *, 9.435784839284958 * 2D0
  591.  
  592. `g77' will interpret the (truncated) constant `9.435784839284958' as a
  593. `REAL(KIND=1)', not `REAL(KIND=2)', constant, because the suffix `D0'
  594. is not specified.
  595.  
  596.    As a result, the output of the above statement when compiled by
  597. `g77' will appear to have "less precision" than when compiled by other
  598. compilers.
  599.  
  600.    In these and other cases, some compilers detect the fact that a
  601. single-precision constant is used in a double-precision context and
  602. therefore interpret the single-precision constant as if it was
  603. *explicitly* specified as a double-precision constant.  (This has the
  604. effect of appending *decimal*, not *binary*, zeros to the fractional
  605. part of the number--producing different computational results.)
  606.  
  607.    The reason this misfeature is dangerous is that a slight, apparently
  608. innocuous change to the source code can change the computational
  609. results.  Consider:
  610.  
  611.      REAL ALMOST, CLOSE
  612.      DOUBLE PRECISION FIVE
  613.      PARAMETER (ALMOST = 5.000000000001)
  614.      FIVE = 5
  615.      CLOSE = 5.000000000001
  616.      PRINT *, 5.000000000001 - FIVE
  617.      PRINT *, ALMOST - FIVE
  618.      PRINT *, CLOSE - FIVE
  619.      END
  620.  
  621. Running the above program should result in the same value being printed
  622. three times.  With `g77' as the compiler, it does.
  623.  
  624.    However, compiled by many other compilers, running the above program
  625. would print two or three distinct values, because in two or three of
  626. the statements, the constant `5.000000000001', which on most systems is
  627. exactly equal to `5.'  when interpreted as a single-precision constant,
  628. is instead interpreted as a double-precision constant, preserving the
  629. represented precision.  However, this "clever" promotion of type does
  630. not extend to variables or, in some compilers, to named constants.
  631.  
  632.    Since programmers often are encouraged to replace manifest constants
  633. or permanently-assigned variables with named constants (`PARAMETER' in
  634. Fortran), and might need to replace some constants with variables
  635. having the same values for pertinent portions of code, it is important
  636. that compilers treat code so modified in the same way so that the
  637. results of such programs are the same.  `g77' helps in this regard by
  638. treating constants just the same as variables in terms of determining
  639. their types in a context-independent way.
  640.  
  641.    Still, there is a lot of existing Fortran code that has been written
  642. to depend on the way other compilers freely interpret constants' types
  643. based on context, so anything `g77' can do to help flag cases of this
  644. in such code could be very helpful.
  645.  
  646. 
  647. File: g77.info,  Node: Equivalence Versus Equality,  Next: Order of Side Effects,  Prev: Context-Sensitive Constants,  Up: Non-bugs
  648.  
  649. Equivalence Versus Equality
  650. ---------------------------
  651.  
  652.    Use of `.EQ.' and `.NE.' on `LOGICAL' operands is not supported,
  653. except via `-fugly', which is not recommended except for legacy code
  654. (where the behavior expected by the *code* is assumed).
  655.  
  656.    Legacy code should be changed, as resources permit, to use `.EQV.'
  657. and `.NEQV.' instead, as these are permitted by the various Fortran
  658. standards.
  659.  
  660.    New code should never be written expecting `.EQ.' or `.NE.'  to work
  661. if either of its operands is `LOGICAL'.
  662.  
  663.    The problem with supporting this "feature" is that there is unlikely
  664. to be consensus on how it works, as illustrated by the following sample
  665. program:
  666.  
  667.      LOGICAL L,M,N
  668.      DATA L,M,N /3*.FALSE./
  669.      IF (L.AND.M.EQ.N) PRINT *,'L.AND.M.EQ.N'
  670.      END
  671.  
  672.    The issue raised by the above sample program is: what is the
  673. precedence of `.EQ.' (and `.NE.') when applied to `LOGICAL' operands?
  674.  
  675.    Some programmers will argue that it is the same as the precedence
  676. for `.EQ.' when applied to numeric (such as `INTEGER') operands.  By
  677. this interpretation, the subexpression `M.EQ.N' must be evaluated first
  678. in the above program, resulting in a program that, when run, does not
  679. execute the `PRINT' statement.
  680.  
  681.    Other programmers will argue that the precedence is the same as the
  682. precedence for `.EQV.', which is restricted by the standards to
  683. `LOGICAL' operands.  By this interpretation, the subexpression
  684. `L.AND.M' must be evaluated first, resulting in a program that *does*
  685. execute the `PRINT' statement.
  686.  
  687.    Assigning arbitrary semantic interpretations to syntactic expressions
  688. that might legitimately have more than one "obvious" interpretation is
  689. generally unwise.
  690.  
  691.    The creators of the various Fortran standards have done a good job
  692. in this case, requiring a distinct set of operators (which have their
  693. own distinct precedence) to compare `LOGICAL' operands.  This
  694. requirement results in expression syntax with more certain precedence
  695. (without requiring substantial context), making it easier for
  696. programmers to read existing code.  `g77' will avoid muddying up
  697. elements of the Fortran language that were well-designed in the first
  698. place.
  699.  
  700.    (Ask C programmers about the precedence of expressions such as `(a)
  701. & (b)' and `(a) - (b)'--they cannot even tell you, without knowing more
  702. context, whether the `&' and `-' operators are infix (binary) or unary!)
  703.  
  704. 
  705. File: g77.info,  Node: Order of Side Effects,  Prev: Equivalence Versus Equality,  Up: Non-bugs
  706.  
  707. Order of Side Effects
  708. ---------------------
  709.  
  710.    `g77' does not necessarily produce code that, when run, performs
  711. side effects (such as those performed by function invocations) in the
  712. same order as in some other compiler--or even in the same order as
  713. another version, port, or invocation (using different command-line
  714. options) of `g77'.
  715.  
  716.    It is never safe to depend on the order of evaluation of side
  717. effects.  For example, an expression like this may very well behave
  718. differently from one compiler to another:
  719.  
  720.      J = IFUNC() - IFUNC()
  721.  
  722. There is no guarantee that `IFUNC' will be evaluated in any particular
  723. order.  Either invocation might happen first.  If `IFUNC' returns 5 the
  724. first time it is invoked, and returns 12 the second time, `J' might end
  725. up with the value `7', or it might end up with `-7'.
  726.  
  727.    Generally, in Fortran, procedures with side-effects intended to be
  728. visible to the caller are best designed as *subroutines*, not functions.
  729. Examples of such side-effects include:
  730.  
  731.    * The generation of random numbers that are intended to influence
  732.      return values.
  733.  
  734.    * Performing I/O (other than internal I/O to local variables).
  735.  
  736.    * Updating information in common blocks.
  737.  
  738.    An example of a side-effect that is not intended to be visible to
  739. the caller is a function that maintains a cache of recently calculated
  740. results, intended solely to speed repeated invocations of the function
  741. with identical arguments.  Such a function can be safely used in
  742. expressions, because if the compiler optimizes away one or more calls
  743. to the function, operation of the program is unaffected (aside from
  744. being speeded up).
  745.  
  746. 
  747. File: g77.info,  Node: Warnings and Errors,  Prev: Non-bugs,  Up: Trouble
  748.  
  749. Warning Messages and Error Messages
  750. ===================================
  751.  
  752.    The GNU compiler can produce two kinds of diagnostics: errors and
  753. warnings.  Each kind has a different purpose:
  754.  
  755.      *Errors* report problems that make it impossible to compile your
  756.      program.  GNU Fortran reports errors with the source file name,
  757.      line number, and column within the line where the problem is
  758.      apparent.
  759.  
  760.      *Warnings* report other unusual conditions in your code that
  761.      *might* indicate a problem, although compilation can (and does)
  762.      proceed.  Warning messages also report the source file name, line
  763.      number, and column information, but include the text `warning:' to
  764.      distinguish them from error messages.
  765.  
  766.    Warnings might indicate danger points where you should check to make
  767. sure that your program really does what you intend; or the use of
  768. obsolete features; or the use of nonstandard features of GNU Fortran.
  769. Many warnings are issued only if you ask for them, with one of the `-W'
  770. options (for instance, `-Wall' requests a variety of useful warnings).
  771.  
  772.    *Note:* Currently, the text of the line and a pointer to the column
  773. is printed in most `g77' diagnostics.  Probably, as of version 0.6,
  774. `g77' will no longer print the text of the source line, instead printing
  775. the column number following the file name and line number in a form
  776. that GNU Emacs recognizes.  This change is expected to speed up and
  777. reduce the memory usage of the `g77' compiler.
  778.  
  779.    *Note Options to Request or Suppress Warnings: Warning Options, for
  780. more detail on these and related command-line options.
  781.  
  782. 
  783. File: g77.info,  Node: Open Questions,  Next: Bugs,  Prev: Trouble,  Up: Top
  784.  
  785. Open Questions
  786. **************
  787.  
  788.    Please consider offering useful answers to these questions!
  789.  
  790.    * How do system administrators and users manage multiple incompatible
  791.      Fortran compilers on their systems?  How can `g77' contribute to
  792.      this, or at least avoiding intefering with it?
  793.  
  794.      Currently, `g77' provides rudimentary ways to choose whether to
  795.      overwrite portions of other Fortran compilation systems (such as
  796.      the `f77' command and the `libf2c' library).  Is this sufficient?
  797.      What happens when users choose not to overwrite these--does `g77'
  798.      work properly in all such installations, picking up its own
  799.      versions, or does it pick up the existing "alien" versions it
  800.      didn't overwrite with its own, possibly leading to subtle bugs?
  801.  
  802.    * `LOC()' and other intrinsics are probably somewhat misclassified.
  803.      Is the a need for more precise classification of intrinsics, and
  804.      if so, what are the appropriate groupings?  Is there a need to
  805.      individually enable/disable/delete/hide intrinsics from the
  806.      command line?
  807.  
  808. 
  809. File: g77.info,  Node: Bugs,  Next: Service,  Prev: Open Questions,  Up: Top
  810.  
  811. Reporting Bugs
  812. **************
  813.  
  814.    Your bug reports play an essential role in making GNU Fortran
  815. reliable.
  816.  
  817.    When you encounter a problem, the first thing to do is to see if it
  818. is already known.  *Note Trouble::.  If it isn't known, then you should
  819. report the problem.
  820.  
  821.    Reporting a bug might help you by bringing a solution to your
  822. problem, or it might not.  (If it does not, look in the service
  823. directory; see *Note Service::.)  In any case, the principal function
  824. of a bug report is to help the entire community by making the next
  825. version of GNU Fortran work better.  Bug reports are your contribution
  826. to the maintenance of GNU Fortran.
  827.  
  828.    Since the maintainers are very overloaded, we cannot respond to every
  829. bug report.  However, if the bug has not been fixed, we are likely to
  830. send you a patch and ask you to tell us whether it works.
  831.  
  832.    In order for a bug report to serve its purpose, you must include the
  833. information that makes for fixing the bug.
  834.  
  835. * Menu:
  836.  
  837. * Criteria: Bug Criteria.    Have you really found a bug?
  838. * Where: Bug Lists.          Where to send your bug report.
  839. * Reporting: Bug Reporting.  How to report a bug effectively.
  840. * Patches: Sending Patches.  How to send a patch for GNU Fortran.
  841.  
  842.    *Note Known Causes of Trouble with GNU Fortran: Trouble, for
  843. information on problems we already know about.
  844.  
  845.    *Note How To Get Help with GNU Fortran: Service, for information on
  846. where to ask for help.
  847.  
  848. 
  849. File: g77.info,  Node: Bug Criteria,  Next: Bug Lists,  Up: Bugs
  850.  
  851. Have You Found a Bug?
  852. =====================
  853.  
  854.    If you are not sure whether you have found a bug, here are some
  855. guidelines:
  856.  
  857.    * If the compiler gets a fatal signal, for any input whatever, that
  858.      is a compiler bug.  Reliable compilers never crash--they just
  859.      remain obsolete.
  860.  
  861.    * If the compiler produces invalid assembly code, for any input
  862.      whatever, that is a compiler bug, unless the compiler reports
  863.      errors (not just warnings) which would ordinarily prevent the
  864.      assembler from being run.
  865.  
  866.    * If the compiler produces valid assembly code that does not
  867.      correctly execute the input source code, that is a compiler bug.
  868.  
  869.      However, you must double-check to make sure, because you might
  870.      have run into an incompatibility between GNU Fortran and
  871.      traditional Fortran.  These incompatibilities might be considered
  872.      bugs, but they are inescapable consequences of valuable features.
  873.  
  874.      Or you might have a program whose behavior is undefined, which
  875.      happened by chance to give the desired results with another
  876.      Fortran compiler.  It is best to check the relevant Fortran
  877.      standard thoroughly if it is possible that the program indeed does
  878.      something undefined.
  879.  
  880.      After you have localized the error to a single source line, it
  881.      should be easy to check for these things.  If your program is
  882.      correct and well defined, you have found a compiler bug.
  883.  
  884.      It might help if, in your submission, you identified the specific
  885.      language in the relevant Fortran standard that specifies the
  886.      desired behavior, if it isn't likely to be obvious and agreed-upon
  887.      by all Fortran users.
  888.  
  889.    * If the compiler produces an error message for valid input, that is
  890.      a compiler bug.
  891.  
  892.    * If the compiler does not produce an error message for invalid
  893.      input, that is a compiler bug.  However, you should note that your
  894.      idea of "invalid input" might be someone else's idea of "an
  895.      extension" or "support for traditional practice".
  896.  
  897.    * If you are an experienced user of Fortran compilers, your
  898.      suggestions for improvement of GNU Fortran are welcome in any case.
  899.  
  900.    Many, perhaps most, bug reports against `g77' turn out to be bugs in
  901. the user's code.  While we find such bug reports educational, they
  902. sometimes take a considerable amount of time to track down or at least
  903. respond to--time we could be spending making `g77', not some user's
  904. code, better.
  905.  
  906.    Some steps you can take to verify that the bug is not certainly in
  907. the code you're compiling with `g77':
  908.  
  909.    * Compile your code using the `g77' options `-W -Wall -O'.  These
  910.      options enable many useful warning; the `-O' option enables flow
  911.      analysis that enables the uninitialized-variable warning.
  912.  
  913.      If you investigate the warnings and find evidence of possible bugs
  914.      in your code, fix them first and retry `g77'.
  915.  
  916.    * Compile your code using the `g77' options `-finit-local-zero',
  917.      `-fno-automatic', `-ffloat-store', and various combinations
  918.      thereof.
  919.  
  920.      If your code works with any of these combinations, that is not
  921.      proof that the bug isn't in `g77'--a `g77' bug exposed by your
  922.      code might simply be avoided, or have a different, more subtle
  923.      effect, when different options are used--but it can be a strong
  924.      indicator that your code is making unawarranted assumptions about
  925.      the Fortran dialect and/or underlying machine it is being compiled
  926.      and run on.
  927.  
  928.      *Note Overly Convenient Command-Line Options: Overly Convenient
  929.      Options, for information on the `-fno-automatic' and
  930.      `-finit-local-zero' options and how to convert their use into
  931.      selective changes in your own code.
  932.  
  933.    * Validate your code with `ftnchek' or a similar code-checking tool.
  934.      `ftncheck' can be found at `ftp://ftp.netlib.org/fortran' or
  935.      `ftp://ftp.dsm.fordham.edu'.
  936.  
  937.    * Try your code out using other Fortran compilers, such as `f2c'.
  938.      If it does not work on at least one other compiler (assuming the
  939.      compiler supports the features the code needs), that is a strong
  940.      indicator of a bug in the code.
  941.  
  942.      However, even if your code works on many compilers *except* `g77',
  943.      that does *not* mean the bug is in `g77'.  It might mean the bug
  944.      is in your code, and that `g77' simply exposes it more readily
  945.      than other compilers.
  946.  
  947. 
  948. File: g77.info,  Node: Bug Lists,  Next: Bug Reporting,  Prev: Bug Criteria,  Up: Bugs
  949.  
  950. Where to Report Bugs
  951. ====================
  952.  
  953.    Send bug reports for GNU Fortran to <fortran@gnu.ai.mit.edu>.
  954.  
  955.    Often people think of posting bug reports to a newsgroup instead of
  956. mailing them.  This sometimes appears to work, but it has one problem
  957. which can be crucial: a newsgroup posting does not contain a mail path
  958. back to the sender.  Thus, if maintainers need more information, they
  959. might be unable to reach you.  For this reason, you should always send
  960. bug reports by mail to the proper mailing list.
  961.  
  962.    As a last resort, send bug reports on paper to:
  963.  
  964.      GNU Compiler Bugs
  965.      Free Software Foundation
  966.      59 Temple Place - Suite 330
  967.      Boston, MA 02111-1307, USA
  968.  
  969.