Composite type formation question

Ron Guilmette rfg at NCD.COM
Sun Feb 17 19:36:04 AEST 1991


In article <948 at edg1.UUCP> jsa at edg1.UUCP (J. Stephen Adamczyk) writes:
+Consider this example:
+
+int f(int (*)[]);
+int f(a)
+int (*a)[3];
+{
+  return sizeof(*a);
+}
+
+I believe the two function types are compatible.  I also believe that a
+composite type should be formed.  3.1.2.6 says
+
+"If only one type is a function type with a parameter type list (a function
+prototype), the composite type is a function prototype with the parameter
+type list."
+
+I believe the second type (in the function definition) does not have
+a "parameter type list," so the above seems to suggest that the composite
+should just be the type
+
+int f(int (*)[])
+
+taking the parameter type list from the prototyped type.  Is that right?

I believe that you are completely correct down to this point.

+If that's the case, does that mean that the sizeof is illegal?

I'm not sure.  While it would seem that the function itself gets a
"composite" type, I think that it is entirely less than clear that
this influences the type of the formal parameter variable `a'.

Either way, this would make an excelent test case for a compiler test
suite!  I feel pretty sure that there is only one "right" answer (even
if I'm not sure what it is).

-- 

// Ron Guilmette  -  C++ Entomologist
// Internet: rfg at ncd.com      uucp: ...uunet!lupine!rfg
// Motto:  If it sticks, force it.  If it breaks, it needed replacing anyway.



More information about the Comp.std.c mailing list