[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] mescc: Fix length calculation of initialized array with unsp
From: |
Janneke Nieuwenhuizen |
Subject: |
Re: [PATCH] mescc: Fix length calculation of initialized array with unspecified length. |
Date: |
Sun, 21 Apr 2024 14:39:06 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Michael Forney writes:
> Consider the following definition:
>
> char a[] = {1, 2, 3};
>
> The initializer is parsed as
>
> ((initzer (initzer-list
> (initzer (p-expr (fixed "1")))
> (initzer (p-expr (fixed "2")))
> (initzer (p-expr (fixed "3"))))))
>
> so (cadar init) is
>
> (initzer-list
> (initzer (p-expr (fixed "1")))
> (initzer (p-expr (fixed "2")))
> (initzer (p-expr (fixed "3"))))
>
> We want to determine the number of items in the initializer, which
> is (length (cdadar init)), not (length (cadar init)).
>
> Using cadar causes the length of the array to be one too large and
> incorrect evaluation of sizeof.
Ouch! Another nice catch; thank you! Applied to `wip'.
Greetings,
Janneke
--
Janneke Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond https://LilyPond.org
Freelance IT https://www.JoyOfSource.com | AvatarĀ® https://AvatarAcademy.com