[Ptach, fortran] PR25818 - Problem with handling optional and entry master arguments

Paul Thomas paulthomas2@wanadoo.fr
Thu Dec 21 22:34:00 GMT 2006


:ADDPATCH fortran:

This patch is adevelopment of one due to Alexander Taeschner.

The problem is that procedures with entries and f77-style assumed shape
arrays need some arithmetic with the array size before the switch on the
entry number.  If the particular entry that is active does not have the
array size as an argument, the inevitable segfault can occur. The fix is
illustrated by the following code produced by the patch:

nran (vector, n)
{
   master.0.nran (0, 0B, n, vector);


nranin (v)
{
   master.0.nran (1, v, 0B, 0B);


master.0.nran (__entry, v, n, vector)
{
   int4 i;
   int4 ubound.0;
   int4 size.1;
   int4 D.1018;
   bit_size_type D.1019;
   <unnamed type> D.1020;

   if (vector != 0B)
     {
       ubound.0 = *n;
       size.1 = NON_LVALUE_EXPR <ubound.0>;
       size.1 = size.1 >= 0 ? size.1 : 0;
       D.1018 = size.1 - 1;
       D.1019 = (bit_size_type) (<unnamed type>) size.1 * 32;
       D.1020 = (<unnamed type>) size.1 * 4;
     }
   else
     {
       (void) 0;
     }
   switch (__entry)
     {
       case 0:;
       goto L.2;
       case 1:;
       goto L.4;

It will be seen that vector and n are not present for entry nranin.
Thus, without the if statement, the assinment of *n to ubound.0 could,
and usually did, cause a segfault.  The patch adds the if statement that
prevents this.  The testscase is the reporter's.

Regtested on Cygwin_NT/amd64 - OK for trunk and 4.2?

Paul



-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Change.Logs
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061221/13f313e3/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr25818.diff
Type: text/x-patch
Size: 3906 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061221/13f313e3/attachment.bin>


More information about the Gcc-patches mailing list