public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/25071]  New: better diagnostic needed
@ 2005-11-26 17:55 jv244 at cam dot ac dot uk
  2005-11-26 19:48 ` [Bug fortran/25071] dummy argument larger than actual argument fxcoudert at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: jv244 at cam dot ac dot uk @ 2005-11-26 17:55 UTC (permalink / raw)
  To: gcc-bugs

using GNU Fortran 95 (GCC) 4.1.0 20051126 (prerelease)  with '-g -pedantic
-std=f95', I get a bad / no diagnostic for the following invalid code:

INTEGER :: I(2,2)
CALL TST(I)
CONTAINS
 SUBROUTINE TST(I)
  INTEGER :: I(6)
 END SUBROUTINE TST
END


-- 
           Summary: better diagnostic needed
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jv244 at cam dot ac dot uk


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


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

* [Bug fortran/25071] dummy argument larger than actual argument
  2005-11-26 17:55 [Bug fortran/25071] New: better diagnostic needed jv244 at cam dot ac dot uk
@ 2005-11-26 19:48 ` fxcoudert at gcc dot gnu dot org
  2007-04-19 15:16 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2005-11-26 19:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from fxcoudert at gcc dot gnu dot org  2005-11-26 19:48 -------
## g95 ##
In file foo.f90:2

CALL TST(I)
          1
Error: Array argument at (1) is smaller than the dummy size
## Intel ##
fortcom: Error: foo.f90, line 2: The storage extent of the dummy argument
exceeds that of the actual argument.   [I]
CALL TST(I)
---------^
fortcom: Info: foo.f90, line 4: This variable has not been used.   [I]
 SUBROUTINE TST(I)
----------------^
compilation aborted for foo.f90 (code 1)
## Portland ##
## Sun ##

CALL TST(I)
         ^
"foo.f90", Line = 2, Column = 10: ERROR: The overall size of the dummy argument
array is greater than the size of this actual argument.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |accepts-invalid
   Last reconfirmed|0000-00-00 00:00:00         |2005-11-26 19:48:38
               date|                            |
            Summary|better diagnostic needed    |dummy argument larger than
                   |                            |actual argument


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


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

* [Bug fortran/25071] dummy argument larger than actual argument
  2005-11-26 17:55 [Bug fortran/25071] New: better diagnostic needed jv244 at cam dot ac dot uk
  2005-11-26 19:48 ` [Bug fortran/25071] dummy argument larger than actual argument fxcoudert at gcc dot gnu dot org
@ 2007-04-19 15:16 ` burnus at gcc dot gnu dot org
  2007-05-03 19:50 ` patchapp at dberlin dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-04-19 15:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2007-04-19 16:16 -------
Analogously for character lengths:

        program test
           character(len=10) :: x
           call foo(x)
           write(*,*) 'X=',x
        contains
        subroutine foo(y)
           character(len=20) :: y
           y = 'hello world'
        end subroutine
       end

Taken from: http://ftp.aset.psu.edu/pub/ger/fortran/test/ test17.f90 (slightly
modified).

g95: Actual character argument at (1) is shorter in length than the formal
argument

NAG f95: Character length too short for arg Y (no. 1) of FOO

ifort: Character length argument mismatch. [X]


-- 


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


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

* [Bug fortran/25071] dummy argument larger than actual argument
  2005-11-26 17:55 [Bug fortran/25071] New: better diagnostic needed jv244 at cam dot ac dot uk
  2005-11-26 19:48 ` [Bug fortran/25071] dummy argument larger than actual argument fxcoudert at gcc dot gnu dot org
  2007-04-19 15:16 ` burnus at gcc dot gnu dot org
@ 2007-05-03 19:50 ` patchapp at dberlin dot org
  2007-05-04  7:54 ` burnus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: patchapp at dberlin dot org @ 2007-05-03 19:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from patchapp at dberlin dot org  2007-05-03 20:50 -------
Subject: Bug number PR25071

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg00186.html


-- 


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


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

* [Bug fortran/25071] dummy argument larger than actual argument
  2005-11-26 17:55 [Bug fortran/25071] New: better diagnostic needed jv244 at cam dot ac dot uk
                   ` (2 preceding siblings ...)
  2007-05-03 19:50 ` patchapp at dberlin dot org
@ 2007-05-04  7:54 ` burnus at gcc dot gnu dot org
  2007-05-04  7:55 ` burnus at gcc dot gnu dot org
  2007-07-24  9:42 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-05-04  7:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2007-05-04 08:54 -------
Subject: Bug 25071

Author: burnus
Date: Fri May  4 07:54:06 2007
New Revision: 124411

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

        PR fortran/25071
        * interface.c (compare_actual_formal): Check character length.

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

        PR fortran/25071
        * gfortran.dg/char_length_3.f90: New test.
        * gfortran.dg/char_result_2.f90: Fix test.


Added:
    trunk/gcc/testsuite/gfortran.dg/char_length_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/char_result_2.f90


-- 


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


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

* [Bug fortran/25071] dummy argument larger than actual argument
  2005-11-26 17:55 [Bug fortran/25071] New: better diagnostic needed jv244 at cam dot ac dot uk
                   ` (3 preceding siblings ...)
  2007-05-04  7:54 ` burnus at gcc dot gnu dot org
@ 2007-05-04  7:55 ` burnus at gcc dot gnu dot org
  2007-07-24  9:42 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-05-04  7:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2007-05-04 08:55 -------
Note: Only the string length problem is fixed; the array storage extend still
needs to be fixed.


-- 


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


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

* [Bug fortran/25071] dummy argument larger than actual argument
  2005-11-26 17:55 [Bug fortran/25071] New: better diagnostic needed jv244 at cam dot ac dot uk
                   ` (4 preceding siblings ...)
  2007-05-04  7:55 ` burnus at gcc dot gnu dot org
@ 2007-07-24  9:42 ` burnus at gcc dot gnu dot org
  5 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-07-24  9:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from burnus at gcc dot gnu dot org  2007-07-24 09:42 -------
I believe this is fixed by PR30940.

The first example gives:
Warnung: Actual argument contains too few elements for dummy argument 'i' (4/6)
at (1)

The second example:
Warnung: Character length of actual argument shorter than of dummy argument 'y'
(10/20) at (1)

It currently gives only warnings since I failed to get any comments when an
error and when only a warning should be given.

Missing is the check for array element designators: PR32616.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug fortran/25071] dummy argument larger than actual argument
       [not found] <bug-25071-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2011-01-27 13:42 ` Joost.VandeVondele at pci dot uzh.ch
@ 2015-09-06  1:08 ` dominiq at lps dot ens.fr
  5 siblings, 0 replies; 13+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-09-06  1:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
No activity for more than four years. AFAICT everything is fixed, but for
comment 7 preferring an error instead of the warning. Since warnings can be
turned into errors with -Werror, I don't think this PR should stay opened.


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

* [Bug fortran/25071] dummy argument larger than actual argument
       [not found] <bug-25071-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2011-01-27 11:02 ` burnus at gcc dot gnu.org
@ 2011-01-27 13:42 ` Joost.VandeVondele at pci dot uzh.ch
  2015-09-06  1:08 ` dominiq at lps dot ens.fr
  5 siblings, 0 replies; 13+ messages in thread
From: Joost.VandeVondele at pci dot uzh.ch @ 2011-01-27 13:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Joost VandeVondele <Joost.VandeVondele at pci dot uzh.ch> 2011-01-27 13:22:49 UTC ---
I actually vaguely recall why this should be a warning, and not be checked for
at runtime. This is for legacy codes using real :: a(1) instead of real ::
a(*). Something like

SUBROUTINE S1(a)
  INTEGER :: a(10)
  a(10)=0
END SUBROUTINE

SUBROUTINE S2(a)
  INTEGER :: a(1)
  CALL S1(a)
END SUBROUTINE

INTEGER :: a(10)
CALL S2(a)
END

'works just fine'...


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

* [Bug fortran/25071] dummy argument larger than actual argument
       [not found] <bug-25071-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-01-25 12:51 ` burnus at gcc dot gnu.org
@ 2011-01-27 11:02 ` burnus at gcc dot gnu.org
  2011-01-27 13:42 ` Joost.VandeVondele at pci dot uzh.ch
  2015-09-06  1:08 ` dominiq at lps dot ens.fr
  5 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-27 11:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-27 09:16:47 UTC ---
(In reply to comment #7)
> Sorry for being 'a bit' late with comments, but IMHO this should be an error
> and not just a warning, because
>
> 2) Other compilers reject it (so we can't argue that we must support this
> common extension)

Well, ifort and pathscale compile w/o warning and g95 with just a warning the
example at:  gfortran.fortran-torture/execute/st_function.f90

Thus, for compare_actual_formal I would make a distinction between:

      /* Special case for character arguments.  For allocatable, pointer
         and assumed-shape dummies, the string length needs to match
         exactly.  */

where I agree that at least for pointer and allocatable an error should be
printed - but probably also for assumed-shape dummies.

And to
      if (actual_size != 0
            && actual_size < formal_size
            && a->expr->ts.type != BT_PROCEDURE)

which can be less problematic and where a warning might be sufficient.


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

* [Bug fortran/25071] dummy argument larger than actual argument
       [not found] <bug-25071-4@http.gcc.gnu.org/bugzilla/>
  2011-01-25 12:41 ` jb at gcc dot gnu.org
  2011-01-25 12:47 ` Joost.VandeVondele at pci dot uzh.ch
@ 2011-01-25 12:51 ` burnus at gcc dot gnu.org
  2011-01-27 11:02 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-01-25 12:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-25 12:41:11 UTC ---
(In reply to comment #8)
> actually, I think this is a kind of error that should be caught at run-time
> with -fcheck=arguments (not to say bounds). I guess that's not so easy to
> implement, as it seem to imply that additional hidden subroutine arguments need
> to be passed around.

Well, that assumes that one compiles all files with the checking option. I like
the idea better to have a global (static, SAVE) derived-type (struct) variable
which contains the arguments and a function pointer. If loc(current function)
== loc(function pointer) then the argument checking is done - else it is for a
different function and no checking is done.


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

* [Bug fortran/25071] dummy argument larger than actual argument
       [not found] <bug-25071-4@http.gcc.gnu.org/bugzilla/>
  2011-01-25 12:41 ` jb at gcc dot gnu.org
@ 2011-01-25 12:47 ` Joost.VandeVondele at pci dot uzh.ch
  2011-01-25 12:51 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Joost.VandeVondele at pci dot uzh.ch @ 2011-01-25 12:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Joost VandeVondele <Joost.VandeVondele at pci dot uzh.ch> 2011-01-25 12:12:59 UTC ---
(In reply to comment #7)
> Reopening..

actually, I think this is a kind of error that should be caught at run-time
with -fcheck=arguments (not to say bounds). I guess that's not so easy to
implement, as it seem to imply that additional hidden subroutine arguments need
to be passed around.


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

* [Bug fortran/25071] dummy argument larger than actual argument
       [not found] <bug-25071-4@http.gcc.gnu.org/bugzilla/>
@ 2011-01-25 12:41 ` jb at gcc dot gnu.org
  2011-01-25 12:47 ` Joost.VandeVondele at pci dot uzh.ch
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: jb at gcc dot gnu.org @ 2011-01-25 12:41 UTC (permalink / raw)
  To: gcc-bugs

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

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |jb at gcc dot gnu.org
         Resolution|FIXED                       |

--- Comment #7 from Janne Blomqvist <jb at gcc dot gnu.org> 2011-01-25 12:01:17 UTC ---
Reopening..

(In reply to comment #6)
> I believe this is fixed by PR30940.
> 
> The first example gives:
> Warnung: Actual argument contains too few elements for dummy argument 'i' (4/6)
> at (1)
> 
> The second example:
> Warnung: Character length of actual argument shorter than of dummy argument 'y'
> (10/20) at (1)
> 
> It currently gives only warnings since I failed to get any comments when an
> error and when only a warning should be given.

Sorry for being 'a bit' late with comments, but IMHO this should be an error
and not just a warning, because

1) The standard says so

2) Other compilers reject it (so we can't argue that we must support this
common extension)

3) Not rejecting it makes it really easy to corrupt memory. Consider

program x
  character(len=10) :: a, b, c
  a = "1234567890"
  b = a
  c = a
  call xx2(b)
  print *, '::', a, '::', b, '::', c, '::'
contains
  subroutine xx2(name)
    character(len=20), intent(inout) :: name
    name = 'hi'
  end subroutine xx2
end program

This prints (gfortran 4.4, x86_64 Linux):

$ ./chardummy2
 ::    567890::hi        ::1234567890::

That is, blanking out the remaining 18 characters at the end of the character b
passed to xx2 overwrites part of the character a (why are only 4 characters
overwritten and not all 10? because they are allocated 4/8/16? byte aligned on
the stack). Note that neither bounds checking nor valgrind detects this error.

> 
> Missing is the check for array element designators: PR32616.

I haven't looked, but maybe PR30940 and PR32616 would need to be fixed as well?


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

end of thread, other threads:[~2015-09-06  1:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-26 17:55 [Bug fortran/25071] New: better diagnostic needed jv244 at cam dot ac dot uk
2005-11-26 19:48 ` [Bug fortran/25071] dummy argument larger than actual argument fxcoudert at gcc dot gnu dot org
2007-04-19 15:16 ` burnus at gcc dot gnu dot org
2007-05-03 19:50 ` patchapp at dberlin dot org
2007-05-04  7:54 ` burnus at gcc dot gnu dot org
2007-05-04  7:55 ` burnus at gcc dot gnu dot org
2007-07-24  9:42 ` burnus at gcc dot gnu dot org
     [not found] <bug-25071-4@http.gcc.gnu.org/bugzilla/>
2011-01-25 12:41 ` jb at gcc dot gnu.org
2011-01-25 12:47 ` Joost.VandeVondele at pci dot uzh.ch
2011-01-25 12:51 ` burnus at gcc dot gnu.org
2011-01-27 11:02 ` burnus at gcc dot gnu.org
2011-01-27 13:42 ` Joost.VandeVondele at pci dot uzh.ch
2015-09-06  1:08 ` dominiq at lps dot ens.fr

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).