Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: multidimensional heap arrays |
| Date | 2011-04-27 14:01 +1200 |
| Message-ID | <91pbmsFq9bU15@mid.individual.net> (permalink) |
| References | (10 earlier) <0.bae52d41338584cfc66d.20110427003859BST.87aafcd1m4.fsf@bsb.me.uk> <91p3udFq9bU13@mid.individual.net> <lnipu0y1dr.fsf@nuthaus.mib.org> <91p8l4Fq9bU14@mid.individual.net> <kfn62q0zdi5.fsf@x-alumni2.alumni.caltech.edu> |
On 04/27/11 01:31 PM, Tim Rentsch wrote: > Ian Collins<ian-news@hotmail.com> writes: > >> On 04/27/11 12:38 PM, Keith Thompson wrote: >>> Ian Collins<ian-news@hotmail.com> writes: >>>> On 04/27/11 11:38 AM, Ben Bacarisse wrote: >>>>> >>>>> The standard can't mandate a type compatibility test that requires an >>>>> arbitrary non-constant expression to be evaluated, so in one way it is >>>>> not surprising that there is no error message. Unfortunately I can't >>>>> square that with the requirement to issue a diagnostic when a pointer to >>>>> an incompatible type is passed to a function. >>>> >>>> I agree. I tried the code with both gcc 4.5.1 (-ansi -Wall -pedantic >>>> -std=c99) and Sun c99. >>>> >>>> I thought a VLA would always have an incompatible type, given its size >>>> isn't known at compile time. In cases like this, I miss C++'s typeid! >>> >>> C99 6.7.5.2p6: >>> >>> For two array types to be compatible, both shall have compatible >>> element types, and if both size specifiers are present, and are >>> integer constant expressions, then both size specifiers shall >>> have the same constant value. If the two array types are used in >>> a context which requires them to be compatible, it is undefined >>> behavior if the two size specifiers evaluate to unequal values. >> >> Ah, so they are incompatible, but no diagnostic was issued by either >> compiler. I'd be interested in seeing if another C99 compiler issues >> one. > > No, a VLA type is compatible with a non-VLA array type if they > have compatible element types. The second sentence of 6.7.5.2p6 > doesn't affect compatibility. It doesn't affect compatibility, but surly passing the address of one to a function expecting a pointer to a fixed size array is "used in a context which requires them to be compatible"? Both compilers issue a diagnostic if the size specifier is not present, ie: extern int x[]; f( &x ); -- Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
multidimensional heap arrays Jack Boot <jackboot@mailinator.com> - 2011-04-25 19:36 +0000
Re: multidimensional heap arrays Francois Grieu <fgrieu@gmail.com> - 2011-04-25 23:16 +0200
Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-25 22:35 +0100
Re: multidimensional heap arrays Anand Hariharan <mailto.anand.hariharan@gmail.com> - 2011-04-25 21:19 -0700
Re: multidimensional heap arrays Francois Grieu <fgrieu@gmail.com> - 2011-04-26 08:19 +0200
Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-26 12:19 +0100
Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-26 23:25 +1200
Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-26 21:06 +0100
Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 08:59 +1200
Re: multidimensional heap arrays Keith Thompson <kst-u@mib.org> - 2011-04-26 14:39 -0700
Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 10:03 +1200
Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-26 23:41 +0100
Re: multidimensional heap arrays Keith Thompson <kst-u@mib.org> - 2011-04-26 16:33 -0700
Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-27 04:05 +0100
Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-26 22:49 +0100
Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 10:19 +1200
Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-27 00:38 +0100
Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 11:48 +1200
Re: multidimensional heap arrays Keith Thompson <kst-u@mib.org> - 2011-04-26 17:38 -0700
Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 13:08 +1200
Re: multidimensional heap arrays Tim Rentsch <txr@alumni.caltech.edu> - 2011-04-26 18:31 -0700
Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 14:01 +1200
Re: multidimensional heap arrays Tim Rentsch <txr@alumni.caltech.edu> - 2011-04-27 00:04 -0700
Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 19:58 +1200
Re: multidimensional heap arrays Ian Collins <ian-news@hotmail.com> - 2011-04-27 20:03 +1200
Re: multidimensional heap arrays Keith Thompson <kst-u@mib.org> - 2011-04-27 00:03 -0700
Re: multidimensional heap arrays Tim Rentsch <txr@alumni.caltech.edu> - 2011-04-26 18:20 -0700
Re: multidimensional heap arrays Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-04-27 03:59 +0100
Re: multidimensional heap arrays Tim Rentsch <txr@alumni.caltech.edu> - 2011-04-27 00:24 -0700
Re: multidimensional heap arrays "io_x" <a@b.c.invalid> - 2011-04-26 09:42 +0200
Re: multidimensional heap arrays Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-04-25 20:50 -0400
Re: multidimensional heap arrays James Kuyper <jameskuyper@verizon.net> - 2011-04-25 22:57 -0400
csiph-web