public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/53175] New: Fortran 4.8 undefined reference to a variable in a module
@ 2012-05-01 17:39 michael.a.richmond at nasa dot gov
  2012-05-02  6:00 ` [Bug fortran/53175] [4.8 Regression] link failure for private module variables used in function specification burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: michael.a.richmond at nasa dot gov @ 2012-05-01 17:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53175

             Bug #: 53175
           Summary: Fortran 4.8 undefined reference to a variable in a
                    module
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: michael.a.richmond@nasa.gov
              Host: i686-pc-linux-gnu
            Target: i686-pc-linux-gnu
             Build: i686-pc-linux-gnu


This error occurs only in gnu Fortran 4.8 dated 04/08/2012 or later.

If I type "gfortran main.f90 e.f90 s.f90" I get the following error message:

/tmp/ccwf6p16.o: In function `default_settings.1813':
s.f90:(.text+0x1b): undefined reference to `__energy_function_MOD_dim'
/tmp/ccwf6p16.o: In function `set_simplex_options.1815':
s.f90:(.text+0x1cd): undefined reference to `__energy_function_MOD_dim'
collect2: error: ld returned 1 exit status

If I concatenate e.f90 and s.f90 so that they are compiled as a single file,
the error goes away.

Listed below are the contents of these files:

main.f90

PROGRAM main
END PROGRAM main

e.f90

MODULE ENERGY_FUNCTION
   IMPLICIT NONE

   TYPE PARAM
      PRIVATE
         INTEGER :: WHICH_VECTOR
   END TYPE PARAM

   INTEGER, PRIVATE :: DIM
   CONTAINS

      FUNCTION ENERGY_FUNCTION_CURRENT_ARGS()
         INTEGER, DIMENSION(DIM) :: ENERGY_FUNCTION_CURRENT_ARGS
      END FUNCTION ENERGY_FUNCTION_CURRENT_ARGS

      FUNCTION ENERGY_FUNCTION_GET_PARAMS()
         TYPE(PARAM), DIMENSION(DIM) :: ENERGY_FUNCTION_GET_PARAMS
      END FUNCTION ENERGY_FUNCTION_GET_PARAMS   

END MODULE ENERGY_FUNCTION

s.f90

MODULE SEARCH_EMIN
   USE ENERGY_FUNCTION
   IMPLICIT NONE
   CONTAINS
     SUBROUTINE SEARCH_EMIN_START()
         TYPE(PARAM), DIMENSION(:), ALLOCATABLE  :: EF_PARAMS
         DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: START_PARAMETERS

         CALL SET_SIMPLEX_OPTIONS

         CONTAINS
            SUBROUTINE SET_SIMPLEX_OPTIONS
               EF_PARAMS = ENERGY_FUNCTION_GET_PARAMS()
               CALL DEFAULT_SETTINGS
            END SUBROUTINE SET_SIMPLEX_OPTIONS

            SUBROUTINE DEFAULT_SETTINGS
               START_PARAMETERS = ENERGY_FUNCTION_CURRENT_ARGS()
            END SUBROUTINE DEFAULT_SETTINGS

         END SUBROUTINE SEARCH_EMIN_START
END MODULE SEARCH_EMIN


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/53175] [4.8 Regression] link failure for private module variables used in function specification
  2012-05-01 17:39 [Bug fortran/53175] New: Fortran 4.8 undefined reference to a variable in a module michael.a.richmond at nasa dot gov
@ 2012-05-02  6:00 ` burnus at gcc dot gnu.org
  2012-05-02 17:16 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-02  6:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53175

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |rejects-valid
   Last reconfirmed|                            |2012-05-02
                 CC|                            |burnus at gcc dot gnu.org
     Ever Confirmed|0                           |1
            Summary|Fortran 4.8 undefined       |[4.8 Regression] link
                   |reference to a variable in  |failure for private module
                   |a module                    |variables used in function
                   |                            |specification
   Target Milestone|---                         |4.8.0

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-02 06:00:08 UTC ---
The regression has been caused by PR 52751 (cf. also PR 40973 and PR 52916).

The patch for those PRs marks the module variable "DIM" as nonpublic, which
increases the optimization possibilities for the compiler. However, "dim" is
used for the type parameter of the result variable of two (public) functions.

The solution is to do the same as for PR 52916 - but this time for module
variables: Setting attr.public_used for the module variable if it is used as
type parameter of public functions - even if those are only available
indirectly via generic interfaces.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/53175] [4.8 Regression] link failure for private module variables used in function specification
  2012-05-01 17:39 [Bug fortran/53175] New: Fortran 4.8 undefined reference to a variable in a module michael.a.richmond at nasa dot gov
  2012-05-02  6:00 ` [Bug fortran/53175] [4.8 Regression] link failure for private module variables used in function specification burnus at gcc dot gnu.org
@ 2012-05-02 17:16 ` burnus at gcc dot gnu.org
  2012-05-04 18:54 ` burnus at gcc dot gnu.org
  2012-05-04 19:28 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-02 17:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53175

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-02 17:15:33 UTC ---
As I have not clearly mentioned it before, there exist the following
workarounds:

a) Make "dim" *not* PRIVATE. ("dim" can be marked as PROTECTED to avoid
unwanted changes.) That might be easier for the real world code than
concatenating files together.

b) Put MODULE ENERGY_FUNCTION into the same file as all the callers of its
functions. (For completeness.)

b) Compile "MODULE ENERGY_FUNCTION" with -O0.

c) Use GCC 4.7 and wait for the patch ;-)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/53175] [4.8 Regression] link failure for private module variables used in function specification
  2012-05-01 17:39 [Bug fortran/53175] New: Fortran 4.8 undefined reference to a variable in a module michael.a.richmond at nasa dot gov
  2012-05-02  6:00 ` [Bug fortran/53175] [4.8 Regression] link failure for private module variables used in function specification burnus at gcc dot gnu.org
  2012-05-02 17:16 ` burnus at gcc dot gnu.org
@ 2012-05-04 18:54 ` burnus at gcc dot gnu.org
  2012-05-04 19:28 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-04 18:54 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53175

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-04 18:54:33 UTC ---
Author: burnus
Date: Fri May  4 18:54:25 2012
New Revision: 187175

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187175
Log:
2012-05-04  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53175
        * resolve.c (resolve_variable): Set public_used
        if a private module variable is used in a (public)
        specification expression.
        * trans-decl.c (gfc_finish_var_decl): Mark those
        TREE_PUBLIC.

2012-05-04  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53175
        gfortran.dg/public_private_module_5.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/public_private_module_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/53175] [4.8 Regression] link failure for private module variables used in function specification
  2012-05-01 17:39 [Bug fortran/53175] New: Fortran 4.8 undefined reference to a variable in a module michael.a.richmond at nasa dot gov
                   ` (2 preceding siblings ...)
  2012-05-04 18:54 ` burnus at gcc dot gnu.org
@ 2012-05-04 19:28 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-04 19:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53175

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-04 19:28:20 UTC ---
FIXED on the trunk (4.8).

Thanks again for the bug report!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-04 19:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-01 17:39 [Bug fortran/53175] New: Fortran 4.8 undefined reference to a variable in a module michael.a.richmond at nasa dot gov
2012-05-02  6:00 ` [Bug fortran/53175] [4.8 Regression] link failure for private module variables used in function specification burnus at gcc dot gnu.org
2012-05-02 17:16 ` burnus at gcc dot gnu.org
2012-05-04 18:54 ` burnus at gcc dot gnu.org
2012-05-04 19:28 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).