doc: Add explanation of zero-length array example

Message ID 20230426161539.1571701-1-jwakely@redhat.com
State Accepted
Headers
Series doc: Add explanation of zero-length array example |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Jonathan Wakely April 26, 2023, 4:15 p.m. UTC
  As suggested here:
https://gcc.gnu.org/pipermail/gcc/2023-April/241190.html

OK for trunk?

-- >8 --

gcc/ChangeLog:

	* doc/extend.texi (Zero Length): Describe example.
---
 gcc/doc/extend.texi | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Richard Biener April 27, 2023, 7:24 a.m. UTC | #1
On Wed, Apr 26, 2023 at 6:16 PM Jonathan Wakely via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> As suggested here:
> https://gcc.gnu.org/pipermail/gcc/2023-April/241190.html
>
> OK for trunk?

OK

> -- >8 --
>
> gcc/ChangeLog:
>
>         * doc/extend.texi (Zero Length): Describe example.
> ---
>  gcc/doc/extend.texi | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
> index 84b44cb9916..06134a50ad2 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -1705,6 +1705,9 @@ struct line *thisline = (struct line *)
>  thisline->length = this_length;
>  @end smallexample
>
> +In this example, @code{thisline->contents} is an array of @code{char} that
> +can hold up to @code{thisline->length} bytes.
> +
>  Although the size of a zero-length array is zero, an array member of
>  this kind may increase the size of the enclosing type as a result of tail
>  padding.  The offset of a zero-length array member from the beginning
> --
> 2.40.0
>
  

Patch

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 84b44cb9916..06134a50ad2 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1705,6 +1705,9 @@  struct line *thisline = (struct line *)
 thisline->length = this_length;
 @end smallexample
 
+In this example, @code{thisline->contents} is an array of @code{char} that
+can hold up to @code{thisline->length} bytes.
+
 Although the size of a zero-length array is zero, an array member of
 this kind may increase the size of the enclosing type as a result of tail
 padding.  The offset of a zero-length array member from the beginning