WG15 Defect Report Ref: 9945-2-101
Topic: Array parameters in bc?

This is an approved interpretation of 9945-2:1993.


Last update: 1997-05-20



	Topic:                Array parameters in bc?
	Relevant Sections:,

Defect Report:
	Date: Thu, 16 Mar 1995 16:50:35 -0800
	From: Phil Nelson <phil@cs.wwu.edu>

In section, the grammar for bc, lines 1635 - 1637 are:

parameter_list : LETTER
	       | define_list ',' LETTER

Where define_list is defined in 1642 - 1646 as:

define_list : LETTER
            | LETTER '[' ']'
            | define_list ',' LETTER
            | define_list ',' LETTER '[' ']'

First, I thought 9945-2:1993 4.3 (bc) did not intend to include array 

The above grammar allows array parameters for ALL except the LAST parameter.
This is rather strange if array parameters were to be included in the

Here is what I would like to know: 

A)  Is line 1636 wrong and should be
		| parameter_list ',' LETTER
	(What I thought it should ... not allow array parameters.)


B)  Does the standard support array parameters and line 1633 would need
	to be changed to allow arrays for *ALL* parameter locations.  The
	change would make 1633 read:
		| define_list

	( It currently reads "| parameter_list" AND such a change would
	  then mean no rule uses the "parameter_list" productions so
	  lines 1635 - 1637 should be removed.)

MY interpretation would be option A from above.

Now to muddy the waters .... in (Extended Description) lines
1389 - 1391 state:

"A whole array passed as an argument shall be specified by the array
name followed by empty square brackets." 

This is not supported by the grammar! (Lines 1662, 1647-1652 (and 1659-1680))

(If you agree with me that A from above is correct, then the lines
1398 - 1391 should be deleted about passing an array.)

Finally, it does appear that IF arrays are allowed as parameters (which
I presumed the standard didn't allow) then they must be "call by value"
arrays.  From line 1391 "All function arguments shall be passed by value."

What is required of a conforming processor?

Interpretation response
According to historic practice on BSD and System V systems, array 
parameters were allowed, just not as the last parameter for arguments.
This does not prevent implementations from allowing array parameters
to be accepted as the last argument.  Lines 1628-1646 on page 202 properly 
define function declarations as per historic practice.

As specified by the standard line 1391 page 196, function arguments are 
"call by value".

The grammer allow functions to be defined taking array parameters
except for the last parameter.  This matches historic practice.  The
grammer however does not allow array arguments to be passed to functions
when they are invoked.  This seems to be a defect.

The standard states the behavior for function declarations for the bc cmd, 
and conforming implementations must conform to this.  However, concerns 
have been raised about this which are being referred to the sponsor.


Forwarded to Interpretations group: Mar 28 1995
Proposed resolution circulated: May 16th
Comments due: June 15th
Finalised: June 16th 1995