Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Martin Sebor via Gcc-patches
On 10/6/20 11:58 AM, Andrew MacLeod wrote: On 10/6/20 1:48 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 01:41:54PM -0400, Andrew MacLeod wrote: On 10/6/20 1:32 PM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 10:42:12AM -0600, Martin Sebor wrote: The manual documents the [

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 2:41 PM, Andreas Schwab wrote: On Okt 06 2020, Andrew MacLeod via Gcc-patches wrote: diff --git a/gcc/value-range.h b/gcc/value-range.h index 7031a823138..02a952bf81f 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -668,13 +668,12 @@ irange_allocator::allocate (unsigned num

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andreas Schwab
On Okt 06 2020, Andrew MacLeod via Gcc-patches wrote: > diff --git a/gcc/value-range.h b/gcc/value-range.h > index 7031a823138..02a952bf81f 100644 > --- a/gcc/value-range.h > +++ b/gcc/value-range.h > @@ -668,13 +668,12 @@ irange_allocator::allocate (unsigned num_pairs) >if (num_pairs < 2) >

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 2:18 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 02:09:42PM -0400, Andrew MacLeod wrote: + size_t nbytes = sizeof (tree) * 2 * num_pairs; + + // Allocate the irnge and required memory for the vector + void *r = (irange *) obstack_alloc (&m_obstack, sizeof (irange)); Then eit

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Tobias Burnus
The following cast looks odd: On 10/6/20 8:09 PM, Andrew MacLeod via Gcc-patches wrote: + // Allocate the irnge and required memory for the vector + void *r = (irange *) obstack_alloc (&m_obstack, sizeof (irange)); Tobias - Mentor Graphics (Deutschland) GmbH, Arnulfstraße 20

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 06, 2020 at 02:09:42PM -0400, Andrew MacLeod wrote: > + size_t nbytes = sizeof (tree) * 2 * num_pairs; > + > + // Allocate the irnge and required memory for the vector > + void *r = (irange *) obstack_alloc (&m_obstack, sizeof (irange)); Then either void *r = (void *) obstack_all

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 1:58 PM, Andrew MacLeod via Gcc-patches wrote: On 10/6/20 1:48 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 01:41:54PM -0400, Andrew MacLeod wrote: On 10/6/20 1:32 PM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 10:42:12AM -0600, Martin Sebor wrote: The manual

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 1:48 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 01:41:54PM -0400, Andrew MacLeod wrote: On 10/6/20 1:32 PM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 10:42:12AM -0600, Martin Sebor wrote: The manual documents the [0] extension and mentions but discourages us

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 06, 2020 at 01:41:54PM -0400, Andrew MacLeod wrote: > On 10/6/20 1:32 PM, Jakub Jelinek via Gcc-patches wrote: > > On Tue, Oct 06, 2020 at 10:42:12AM -0600, Martin Sebor wrote: > > > The manual documents the [0] extension and mentions but discourages > > > using [1]. Nothing is said ab

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 1:32 PM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 10:42:12AM -0600, Martin Sebor wrote: The manual documents the [0] extension and mentions but discourages using [1]. Nothing is said about other sizes and the warnings such as -Warray-bounds have been increasingly

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 06, 2020 at 10:42:12AM -0600, Martin Sebor wrote: > The manual documents the [0] extension and mentions but discourages > using [1]. Nothing is said about other sizes and the warnings such > as -Warray-bounds have been increasingly complaining about accesses > past the declared constan

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Martin Sebor via Gcc-patches
On 10/6/20 1:52 AM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 09:37:21AM +0200, Aldy Hernandez via Gcc-patches wrote: Pushed as obvious. gcc/ChangeLog: * value-range.h (irange_allocator::allocate): Increase newir storage by one. --- gcc/value-range.h | 2 +-

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 8:55 AM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 08:47:53AM -0400, Andrew MacLeod wrote: I think the proper alignment will be guaranteed if irange and tree[] are obstack_alloc'd separately. They don't need to be adjacent, do they? They do not, it just seemed wasteful to do 2

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 06, 2020 at 08:47:53AM -0400, Andrew MacLeod wrote: > > I think the proper alignment will be guaranteed if irange and tree[] are > > obstack_alloc'd separately. They don't need to be adjacent, do they? > > > > > They do not, it just seemed wasteful to do 2 allocs each time, and it'd

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 6:22 AM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 11:20:52AM +0200, Aldy Hernandez wrote: diff --git a/gcc/value-range.h b/gcc/value-range.h index 94b48e55e77..7031a823138 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -670,7 +670,7 @@ irange_allocator::

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 6:40 AM, Andreas Schwab wrote: On Okt 06 2020, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 10:47:34AM +0200, Andreas Schwab wrote: On Okt 06 2020, Jakub Jelinek via Gcc-patches wrote: I mean, we could just use: size_t nbytes = sizeof (irange) + sizeof (tree) * 2 * num_pairs;

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andreas Schwab
On Okt 06 2020, Jakub Jelinek wrote: > On Tue, Oct 06, 2020 at 10:47:34AM +0200, Andreas Schwab wrote: >> On Okt 06 2020, Jakub Jelinek via Gcc-patches wrote: >> >> > I mean, we could just use: >> > size_t nbytes = sizeof (irange) + sizeof (tree) * 2 * num_pairs; >> > irange *r = (irange *) o

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 06, 2020 at 11:20:52AM +0200, Aldy Hernandez wrote: > > > diff --git a/gcc/value-range.h b/gcc/value-range.h > > > index 94b48e55e77..7031a823138 100644 > > > --- a/gcc/value-range.h > > > +++ b/gcc/value-range.h > > > @@ -670,7 +670,7 @@ irange_allocator::allocate (unsigned num_pairs)

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Aldy Hernandez via Gcc-patches
On 10/6/20 9:52 AM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 09:37:21AM +0200, Aldy Hernandez via Gcc-patches wrote: Pushed as obvious. gcc/ChangeLog: * value-range.h (irange_allocator::allocate): Increase newir storage by one. --- gcc/value-range.h | 2 +- 1 file cha

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 06, 2020 at 10:47:34AM +0200, Andreas Schwab wrote: > On Okt 06 2020, Jakub Jelinek via Gcc-patches wrote: > > > I mean, we could just use: > > size_t nbytes = sizeof (irange) + sizeof (tree) * 2 * num_pairs; > > irange *r = (irange *) obstack_alloc (&m_obstack, nbytes); > > retu

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andreas Schwab
On Okt 06 2020, Jakub Jelinek via Gcc-patches wrote: > I mean, we could just use: > size_t nbytes = sizeof (irange) + sizeof (tree) * 2 * num_pairs; > irange *r = (irange *) obstack_alloc (&m_obstack, nbytes); > return new (r) irange ((tree *) (r + 1), num_pairs); > without any new type. Mo

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Jakub Jelinek via Gcc-patches
On Tue, Oct 06, 2020 at 09:37:21AM +0200, Aldy Hernandez via Gcc-patches wrote: > Pushed as obvious. > > gcc/ChangeLog: > > * value-range.h (irange_allocator::allocate): Increase > newir storage by one. > --- > gcc/value-range.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-)

[PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Aldy Hernandez via Gcc-patches
Pushed as obvious. gcc/ChangeLog: * value-range.h (irange_allocator::allocate): Increase newir storage by one. --- gcc/value-range.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/value-range.h b/gcc/value-range.h index 94b48e55e77..7031a823138 100644 --