* cc's func prototypes not ANSI?
@ 1999-04-13 4:00 Jeff Sullivan
1999-04-13 4:00 ` Jeff Sullivan
1999-04-13 4:00 ` Jeff Sullivan
0 siblings, 2 replies; 3+ messages in thread
From: Jeff Sullivan @ 1999-04-13 4:00 UTC (permalink / raw)
This was originally posted in comp.unix.osf.misc (see below).
I will answer it here.
Subject: cc's func prototypes not ANSI?
Date: 28 Mar 1999 20:31:47 GMT
From: bernhard@alpha1.csd.uwm.edu (Bernhard Reiter)
Organization: University of Wisconsin - Milwaukee
Newsgroups: comp.unix.osf.misc
cc probe.c
cc: Error: probe.c, line 2: In the declaration of an unnamed object, the array
bounds are incorrectly specified.
int y(char [][]);
- -----------^
The Declaration thows cc off. It seems to be ANSI-C, but I am not sure.
One-dim arrays in function declarations work fine.
Is it a bug in DEC's cc?
Is this the right place to ask this? ;)
Bernhard
OSF1 V4.0 878 alpha
DEC C V5.6-079 on Digital UNIX V4.0 (Rev. 878)
probe.c follows:
int x(char []);
int y(char [][]);
int x(char z[2]){
return 0;
}
int y(char z[3][2]){
return 0;
}
int main(void) {
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: cc's func prototypes not ANSI?
1999-04-13 4:00 cc's func prototypes not ANSI? Jeff Sullivan
@ 1999-04-13 4:00 ` Jeff Sullivan
1999-04-13 4:00 ` Jeff Sullivan
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Sullivan @ 1999-04-13 4:00 UTC (permalink / raw)
In response to Bernhard's question, we have modified the
compiler to allow parameter declarations such as:
void f(int a[][], int b[][][]);
The first is actually allowed by the Standard. The second
in non-standard, but gcc accepts it. Optional messages
can be output for both types.
This change will be available in the Compaq C (formerly DEC C)
compiler in the release after Tru64 UNIX V5.0. The change will
also be available in our Developer's Toolkit compiler, which
is in field test now.
-Jeff
--
Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com
DEC C and C++ | Nashua, NH ZK3-2/X29 | Jeff.Sullivan@compaq.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: cc's func prototypes not ANSI?
1999-04-13 4:00 cc's func prototypes not ANSI? Jeff Sullivan
1999-04-13 4:00 ` Jeff Sullivan
@ 1999-04-13 4:00 ` Jeff Sullivan
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Sullivan @ 1999-04-13 4:00 UTC (permalink / raw)
Below is some of the analysis from our ANSI experts:
In ANSI 3.1.2.5 (ISO 6.1.2.5) Types, we have "An array type describes a
contiguously allocated nonempty set of objects with a particular member
object type called the element type." This is footnoted to say that
since object types do not include incomplete types, an array of incomplete
type cannot be constructed.
In the particular case of parameter declarations, 3.5.4.3 Function
declarators (including prototypes) says that "For each parameter declared
with function or array type, its type for these comparisons is the one that
results from conversion to a pointer type, as in 3.7.1". 3.7.1 Function
definitions says that "A declaration of a parameter as array of type shall
be adjusted to pointer to type." So when analyzing the type compatibility
of a function declared "int foo(int i[]);", the type is first adjusted to
"int foo(int (*i));". Similarly, analyzing "int foo(int i[][]);" would
involve adjustment to "int foo(int (*i)[]);" - the parameter is a pointer
to an incomplete array type. 3.1.2.6 Compatible type and composite type
includes an example showing that a parameter that is a pointer to an
incomplete array type can participate in forming a composite type with
the array type completed, as in the pair of declarations:
int f(double (*)[]);
int f(double (*)[3]);
We certainly allow:
int y(char (*)[]);
int y(char z[3][2]){
return 0;
}
and so I think we also ought to allow the equivalent:
int y(char [][]);
int y(char z[3][2]){
return 0;
}
But you only get the outermost array syntax converted to a pointer.
A declaration with three dimensions like "int foo(int a[][][]);"
is adjusted to "int foo(int (*a)[][]);" which is a pointer to
an incomplete array of incomplete element type, which is not
allowed. However, I notice that gcc -ansi -pedantic silently
accepts this construct as well.
--
Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com
DEC C and C++ | Nashua, NH ZK3-2/X29 | Jeff.Sullivan@compaq.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-04-13 4:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-04-13 4:00 cc's func prototypes not ANSI? Jeff Sullivan
1999-04-13 4:00 ` Jeff Sullivan
1999-04-13 4:00 ` Jeff Sullivan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox