Public Comment Number PC-UK0171 ISO/IEC CD 9899 (SC22N2620) Public Comment =========================================== Date: 1998-03-26 Author: N.M Maclaren Author Affiliation: Self Postal Address: University of Cambridge, Computer Laboratory, New Museums Site, Pembroke Street, Cambridge CB3 3QG, United Kingdom E-mail Address: Telephone Number: +44 1223 334761 Fax Number: +44 1223 334679 Number of individual comments: 1 Comment 1. Category: Normative change to existing feature retaining the original intent Committee Draft subsection: 6.5.5.2 Title: Ambiguities and traps in VLAs Detailed description: Paragraph 3 says that it is unspecified whether side-effects in the sizes of VLA declarators occur. I am at a loss to understand why this exclusion is necessary or desirable, and its current wording is nothing but a trap for the programmer. In particular, it conflicts very badly with the IEEE and LIA arithmetic standards in that it explicitly permits exceptions to occur and not be flagged. Furthermore, there is no requirement that side-effects be handled consistently, even for textually identical declarators within the same function. Programmers will not expect such bizarre behaviour. But perhaps the worst aspect is that it is unclear whether this lack of specification is permitted to change the actual size, as in declarers like: int m = 10, n = 3; typedef double x[(m += 10, ++n, m+n)]; As the wording stands, it is unspecified whether this allocates an array of length 13, 14, 23 or 24. I am sure that this was not meant, but it is what the wording says. Worse still, consider a machine with 32-bit integers and 16-bit operations - is it allowed to update only half of an integer? This situation is a recipe for chaos, and needs resolution. I suggest one of the following solutions: 1) To define that side-effects occur as in ordinary expressions. Algol 68 and other languages have shown that this is technically simple, though existing compilers might need some reorganisation. There should be no need for incompatible changes to compiled code. After all, the compiler has to permit a function call, which can then do anything! 2) To make it a constraint error to use a VLA size expression that has a side-effect or calls a function. This would permit almost all 'reasonable' uses, diagnose those that were invalid and give the implementor a very easy time. I doubt that most programmers would ever notice the restriction.