Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jun 1999 07:57:16 -0700 (PDT)
From:      dima@server.ru
To:        freebsd-gnats-submit@freebsd.org
Subject:   bin/12431: f2c works incorrectly with arguments of subroutine with multiple entry points
Message-ID:  <19990628145716.99A6B1515E@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         12431
>Category:       bin
>Synopsis:       f2c works incorrectly with arguments of subroutine with multiple entry points
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 28 08:00:00 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry Kazarov
>Release:        
>Organization:
Server Inc
>Environment:
>Description:
The arguments of subroutine with multiple entry points could be used as any other variables anywhere withing body of subroutine.
So argument of one entry point (or it's value) should be copied to local static variable if it used in the call to other entry point.

This is valid FORTRAN code (works with many FORTRAN compilers but f2c):
	subroutine a(x, y, z)
	z=x+y
	return
	entry b(i)
	i=z
	return
	end
f2c will produce this C code:
/* Subroutine */ int a_0_(n__, x, y, z__, i__)
int n__;
real *x, *y, *z__;
integer *i__;
{
    switch(n__) {
	case 1: goto L_b;
	}

    *z__ = *x + *y;
    return 0;

L_b:
    *i__ = *z__;
    return 0;
} /* a_ */

/* Subroutine */ int a_(x, y, z__)
real *x, *y, *z__;
{
    return a_0_(0, x, y, z__, (integer *)0);
    }

/* Subroutine */ int b_(i__)
integer *i__;
{
    return a_0_(1, (real *)0, (real *)0, (real *)0, i__);
    }

On the call to b argument z points to 0, what cause core dump.
>How-To-Repeat:

>Fix:
Before exit from functions generated for entry points values of arguments should be copied to static variables. In calls to common function all pointers to 0 should be changed to pointers to that static variables.

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990628145716.99A6B1515E>