🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2438

Re: Composite type formation question

#2438
From: Ron Guilmette
Date: Sun, 17 Feb 1991 08:36
42 lines
1877 bytes
In article <948@edg1.UUCP> jsa@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@ncd.com      uucp: ...uunet!lupine!rfg
// Motto:  If it sticks, force it.  If it breaks, it needed replacing anyway.
Technical Details
Message-ID: <3947@lupine.NCD.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!spool.mu.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!infopiz!lupine!rfg
References: <948@edg1.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!spool.mu.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!infopiz!lupine!rfg
From: rfg@NCD.COM (Ron Guilmette)
Newsgroups: comp.std.c
Subject: Re: Composite type formation question
Message-ID: <3947@lupine.NCD.COM>
Date: 17 Feb 91 08:36:04 GMT
References: <948@edg1.UUCP>
Organization: Network Computing Devices, Inc., Mt. View, CA
Lines: 42