public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/28443]  New: gfortran does not implement the present intrinsic procedure correctly for optional character strings
@ 2006-07-20 10:21 cyan+gcc at compsoc dot nuigalway dot ie
  2006-07-20 19:53 ` [Bug fortran/28443] " steven at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: cyan+gcc at compsoc dot nuigalway dot ie @ 2006-07-20 10:21 UTC (permalink / raw)
  To: gcc-bugs

In file strpresent.F90:

program test_string_present

    call test_present(1, "foo")
    call test_present(2)

end program

subroutine test_present(a, b)
    integer :: a
    character*(*), optional :: b

    if (present(b)) then
        write (0,*) "b is present."
    else
        write (0,*) "b is not present."
    end if

end subroutine test_present

As of SVN revision 115597, this yields the output:

 b is present.
 b is present.

It appears that the present() intrinsic function isn't working correctly for
optional character strings.

Ifort yields the expected output:

 b is present.
 b is not present.

The output of gfortran -v -save-temps -o strpresent strpresent.F90:

Driving: gfortran -v -save-temps -o strpresent strpresent.F90 -lgfortranbegin
-lgfortran -lm -shared-libgcc
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/pfarrell/redhat/BUILD/gcc4-115597/configure
--prefix=/opt/packages/gcc4 --enable-bootstrap --enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.2.0 20060719 (experimental)
 /opt/packages/gcc4/libexec/gcc/i686-pc-linux-gnu/4.2.0/cc1 -E -lang-fortran
-traditional-cpp -D_LANGUAGE_FORTRAN -quiet -v strpresent.F90 -mtune=generic
-fpch-preprocess -o strpresent.f95
ignoring nonexistent directory
"/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /opt/packages/gcc4/include
 /opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/include
 /usr/include
End of search list.
 /opt/packages/gcc4/libexec/gcc/i686-pc-linux-gnu/4.2.0/f951 strpresent.f95
-ffree-form -quiet -dumpbase strpresent.F90 -mtune=generic -auxbase strpresent
-version -fpreprocessed -I
/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/finclude -o strpresent.s
GNU F95 version 4.2.0 20060719 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.2.0 20060719 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 as -V -Qy -o strpresent.o strpresent.s
GNU assembler version 2.15.92.0.2 (i386-redhat-linux) using BFD version
2.15.92.0.2 20040927
 /opt/packages/gcc4/libexec/gcc/i686-pc-linux-gnu/4.2.0/collect2 --eh-frame-hdr
-m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o strpresent /usr/lib/crt1.o
/usr/lib/crti.o /opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/crtbegin.o
-L/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0
-L/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/../../.. strpresent.o
-lgfortranbegin -lgfortran -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/opt/packages/gcc4/lib/gcc/i686-pc-linux-gnu/4.2.0/crtend.o /usr/lib/crtn.o


-- 
           Summary: gfortran does not implement the present intrinsic
                    procedure correctly for optional character strings
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cyan+gcc at compsoc dot nuigalway dot ie
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug fortran/28443] gfortran does not implement the present intrinsic procedure correctly for optional character strings
  2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
@ 2006-07-20 19:53 ` steven at gcc dot gnu dot org
  2006-07-20 21:17 ` steven at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-07-20 19:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from steven at gcc dot gnu dot org  2006-07-20 19:53 -------
Confirmed.


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
  GCC build triplet|i686-pc-linux-gnu           |
   GCC host triplet|i686-pc-linux-gnu           |
 GCC target triplet|i686-pc-linux-gnu           |
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2006-07-20 19:53:45
               date|                            |


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


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

* [Bug fortran/28443] gfortran does not implement the present intrinsic procedure correctly for optional character strings
  2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
  2006-07-20 19:53 ` [Bug fortran/28443] " steven at gcc dot gnu dot org
@ 2006-07-20 21:17 ` steven at gcc dot gnu dot org
  2006-07-21  8:11 ` matthias dot langer at zamg dot ac dot at
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-07-20 21:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from steven at gcc dot gnu dot org  2006-07-20 21:17 -------
>From the tree dumps, it would appear we totally mis-handle omitted arguments:

;; Function MAIN__ (MAIN__)

MAIN__ ()
{
<bb 2>:
  _gfortran_set_std (70, 127, 0);
  test_present (&C.1239, &C.1240);
  test_present (&C.1242);
  return;

}


-- 


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


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

* [Bug fortran/28443] gfortran does not implement the present intrinsic procedure correctly for optional character strings
  2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
  2006-07-20 19:53 ` [Bug fortran/28443] " steven at gcc dot gnu dot org
  2006-07-20 21:17 ` steven at gcc dot gnu dot org
@ 2006-07-21  8:11 ` matthias dot langer at zamg dot ac dot at
  2006-07-21 19:31 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: matthias dot langer at zamg dot ac dot at @ 2006-07-21  8:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from matthias dot langer at zamg dot ac dot at  2006-07-21 08:11 -------
Created an attachment (id=11917)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11917&action=view)
comment


-- 


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


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

* [Bug fortran/28443] gfortran does not implement the present intrinsic procedure correctly for optional character strings
  2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
                   ` (2 preceding siblings ...)
  2006-07-21  8:11 ` matthias dot langer at zamg dot ac dot at
@ 2006-07-21 19:31 ` pinskia at gcc dot gnu dot org
  2006-07-21 23:34 ` steven at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-07-21 19:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pinskia at gcc dot gnu dot org  2006-07-21 19:31 -------
Yes, this is most likely one of the accepts invalid bugs where gfortran does
not check the types of functions arguments already implicatedly defined.


-- 


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


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

* [Bug fortran/28443] gfortran does not implement the present intrinsic procedure correctly for optional character strings
  2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
                   ` (3 preceding siblings ...)
  2006-07-21 19:31 ` pinskia at gcc dot gnu dot org
@ 2006-07-21 23:34 ` steven at gcc dot gnu dot org
  2006-07-22  8:32 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: steven at gcc dot gnu dot org @ 2006-07-21 23:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from steven at gcc dot gnu dot org  2006-07-21 23:34 -------
Lahey agrees that this is invalid code:

          1        program test_string_present
          2        
          3            call test_present(1, "foo")
          4            call test_present(2)
          5        
          6        end program
          7        
          8        subroutine test_present(a, b)
          9            integer :: a
         10            character*(*), optional :: b
         11        
         12     1      if (present(b)) then
         13     1          write (0,*) "b is present."
         14     1      else
         15     1          write (0,*) "b is not present."
         16     1      end if
         17        
         18        end subroutine test_present


line 8: Dummy argument 'a' not used in this subprogram.
line 8: The previously procedure 'test_present' reference in 'line 3' shall
have the explicit interface, because that has the optional argument 'b'.
line 8: The argument number of procedure 'test_present' shall be the same
between definition and reference. The previous appearance is in 'line 4'.


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid


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


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

* [Bug fortran/28443] gfortran does not implement the present intrinsic procedure correctly for optional character strings
  2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
                   ` (4 preceding siblings ...)
  2006-07-21 23:34 ` steven at gcc dot gnu dot org
@ 2006-07-22  8:32 ` pinskia at gcc dot gnu dot org
  2006-07-24 19:30 ` fxcoudert at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-07-22  8:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-07-22 08:32 -------
PR 26227 is the bug about accepting invalid code with different types and
numbers of dummy arguments.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |26227


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


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

* [Bug fortran/28443] gfortran does not implement the present intrinsic procedure correctly for optional character strings
  2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
                   ` (5 preceding siblings ...)
  2006-07-22  8:32 ` pinskia at gcc dot gnu dot org
@ 2006-07-24 19:30 ` fxcoudert at gcc dot gnu dot org
  2006-08-04  7:50 ` paul dot richard dot thomas at cea dot fr
  2006-09-13 16:11 ` tobi at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-07-24 19:30 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal


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


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

* [Bug fortran/28443] gfortran does not implement the present intrinsic procedure correctly for optional character strings
  2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
                   ` (6 preceding siblings ...)
  2006-07-24 19:30 ` fxcoudert at gcc dot gnu dot org
@ 2006-08-04  7:50 ` paul dot richard dot thomas at cea dot fr
  2006-09-13 16:11 ` tobi at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: paul dot richard dot thomas at cea dot fr @ 2006-08-04  7:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from paul dot richard dot thomas at cea dot fr  2006-08-04 07:50 -------
Just to reinforce the above, I should remark that an explicit interface in the
main program makes the code behave correctly (see below).

The standard requires that references to a procedure with an implicit interface
have the same number of actual arguments with the same type characteristics.

As Andrew says, gfortran does not check implicitly defined procedure arguments;
either for consistency of references within one scope or for a formal interface
generated by the procedure happening to be in the same file.

Paul

program test_string_present
    interface
      subroutine test_present(a, b)
        integer :: a
        character*(*), optional :: b
      end subroutine test_present
    end interface

    call test_present(1, "foo")
    call test_present(2)

end program

subroutine test_present(a, b)
    integer :: a
    character*(*), optional :: b

    if (present(b)) then
        write (0,*) "b is present."
    else
        write (0,*) "b is not present."
    end if

end subroutine test_present


-- 


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


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

* [Bug fortran/28443] gfortran does not implement the present intrinsic procedure correctly for optional character strings
  2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
                   ` (7 preceding siblings ...)
  2006-08-04  7:50 ` paul dot richard dot thomas at cea dot fr
@ 2006-09-13 16:11 ` tobi at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: tobi at gcc dot gnu dot org @ 2006-09-13 16:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from tobi at gcc dot gnu dot org  2006-09-13 16:11 -------
This is another variation of the theme in 26227

*** This bug has been marked as a duplicate of 26227 ***


-- 

tobi at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2006-09-13 16:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-20 10:21 [Bug fortran/28443] New: gfortran does not implement the present intrinsic procedure correctly for optional character strings cyan+gcc at compsoc dot nuigalway dot ie
2006-07-20 19:53 ` [Bug fortran/28443] " steven at gcc dot gnu dot org
2006-07-20 21:17 ` steven at gcc dot gnu dot org
2006-07-21  8:11 ` matthias dot langer at zamg dot ac dot at
2006-07-21 19:31 ` pinskia at gcc dot gnu dot org
2006-07-21 23:34 ` steven at gcc dot gnu dot org
2006-07-22  8:32 ` pinskia at gcc dot gnu dot org
2006-07-24 19:30 ` fxcoudert at gcc dot gnu dot org
2006-08-04  7:50 ` paul dot richard dot thomas at cea dot fr
2006-09-13 16:11 ` tobi at gcc dot gnu dot 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).