This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: Fix calculation of size of builtin setjmp buffer
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 6 May 2014 15:15:36 +0200
- Subject: Re: RFA: Fix calculation of size of builtin setjmp buffer
- Authentication-results: sourceware.org; auth=none
- References: <87wqdzjccp dot fsf at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, May 06, 2014 at 01:55:18PM +0100, Nick Clifton wrote:
> 2014-05-06 Nick Clifton <nickc@redhat.com>
>
> * except.c (init_eh): Fix computation of builtin setjmp buffer
> size.
>
> Index: gcc/except.c
> ===================================================================
> --- gcc/except.c (revision 210096)
> +++ gcc/except.c (working copy)
> @@ -287,7 +287,7 @@
> #endif
> #else
> /* builtin_setjmp takes a pointer to 5 words. */
> - tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
> + tmp = size_int (5 * POINTER_SIZE / BITS_PER_WORD - 1);
> #endif
> tmp = build_index_type (tmp);
> tmp = build_array_type (ptr_type_node, tmp);
That doesn't look correct to me. If the code wants to create 5 words long
array, but with pointer elements (instead of word sized elements), then
5 * BITS_PER_WORD is the desired size in bits of the buffer, POINTER_SIZE
is how many bits each void *array[...] element occupies and thus
5 * BITS_PER_WORD / POINTER_SIZE - 1 is the right last element, so I'd
say the previous expression is the right one. Perhaps you want to round up
rather than down, but certainly not swap the division operands.
Now, if the code actually expects 5 pointers, rather than 5 words, or
something else, then you'd at least need to also fix the comment.
Jakub