https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51820

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Is the following patch a step in the right direction?

--- ../_clean/gcc/fortran/invoke.texi   2016-03-13 09:07:16.000000000 +0100
+++ gcc/fortran/invoke.texi     2016-04-09 15:58:43.000000000 +0200
@@ -1283,9 +1284,18 @@ Do not transform names of entities speci
 source file by appending underscores to them.

 With @option{-funderscoring} in effect, GNU Fortran appends one
-underscore to external names with no underscores.  This is done to ensure
+underscore to external names.  This is done to ensure
 compatibility with code produced by many UNIX Fortran compilers.

+Note that this applies  only to "F77" names, as modules, OOP stuff,
+@code{bind(c)}, and other modernities are mangled differently
+(or for plain @code{bind(C)}, never mangled), and is not modifiable
+by these command-line options.
+
+Also note that @code{bind(C)} is a more robust way to create external
+symbols with some specific name, rather than playing with compiler
+options.
+
 @emph{Caution}: The default behavior of GNU Fortran is
 incompatible with @command{f2c} and @command{g77}, please use the
 @option{-ff2c} option if you want object files compiled with
@@ -1306,7 +1316,7 @@ I = J() + MAX_COUNT (MY_VAR, LVAR)
 @noindent
 is implemented as something akin to:
 @smallexample
-i = j_() + max_count__(&my_var__, &lvar);
+i = j_() + max_count_(&my_var_, &lvar);
 @end smallexample

 With @option{-fno-underscoring}, the same statement is implemented as:
@@ -1336,11 +1346,11 @@ could make finding unresolved-reference 
 cases---they might occur at program run time, and show up only as
 buggy behavior at run time.

-In future versions of GNU Fortran we hope to improve naming and linking
-issues so that debugging always involves using the names as they appear
-in the source, even if the names as seen by the linker are mangled to
-prevent accidental linking between procedures with incompatible
-interfaces.
+%In future versions of GNU Fortran we hope to improve naming and linking
+%issues so that debugging always involves using the names as they appear
+%in the source, even if the names as seen by the linker are mangled to
+%prevent accidental linking between procedures with incompatible
+%interfaces.

 @item -fsecond-underscore
 @opindex @code{fsecond-underscore}
@@ -1355,8 +1365,7 @@ By default, GNU Fortran appends an under
 names.  If this option is used GNU Fortran appends two
 underscores to names with underscores and one underscore to external names
 with no underscores.  GNU Fortran also appends two underscores to
-internal names with underscores to avoid naming collisions with external
-names.
+internal names with underscores.

 This option has no effect if @option{-fno-underscoring} is
 in effect.  It is implied by the @option{-ff2c} option.

Reply via email to