tag:blogger.com,1999:blog-654279083390275842.post4836384958873134077..comments2024-03-19T12:22:43.654+03:00Comments on Размышлизмы eao197: [prog.c++] Пустой массив в структуреeao197http://www.blogger.com/profile/17283739752119445290noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-654279083390275842.post-21835622317386474342010-03-03T22:41:44.087+02:002010-03-03T22:41:44.087+02:00Спасибо за цитату. Я предполагал, что это стандарт...Спасибо за цитату. Я предполагал, что это стандартизированная штука. Но знатоком стандартов никогда не был.eao197https://www.blogger.com/profile/17283739752119445290noreply@blogger.comtag:blogger.com,1999:blog-654279083390275842.post-76037398853657822352010-03-03T21:48:07.187+02:002010-03-03T21:48:07.187+02:00Этот момент в стандарте прописан. В C99 - раздел 6...Этот момент в стандарте прописан. В C99 - раздел 6.7.2.1.16:<br /><br /><i>As a special case, the last element of a structure with more than one named member may<br />have an incomplete array type; this is called a flexible array member. In most situations,<br />the flexible array member is ignored. In particular, the size of the structure is as if the<br />flexible array member were omitted except that it may have more trailing padding than<br />the omission would imply. However, when a . (or ->) operator has a left operand that is<br />(a pointer to) a structure with a flexible array member and the right operand names that<br />member, it behaves as if that member were replaced with the longest array (with the same<br />element type) that would not make the structure larger than the object being accessed; the<br />offset of the array shall remain that of the flexible array member, even if this would differ<br />from that of the replacement array. If this array would have no elements, it behaves as if<br />it had one element but the behavior is undefined if any attempt is made to access that<br />element or to generate a pointer one past it.</i><br /><br />Насколько я понимаю, здесь утверждается, что нет чёткой гарантии будет или не будет сколько-то места, но если специально место не выделялось, то стоит предполагать, что его там нет.Stanhttps://www.blogger.com/profile/14905559699740229859noreply@blogger.com