Re: pointer addition and arrays

2023-12-02 Thread Bruno Haible
Andreas F. Borchert wrote: > > I still don't know whether it's OK to have pointers to arrays with > > 0 elements (which are not "array objects", since "objects" are non- > > empty (§ 6.2.6.1.(2))). > > From § 6.7.6.2 about array declarators: > >If the expression is a constant expression, it s

Re: undefined-behavior obstack.c:139

2023-12-02 Thread Andreas F. Borchert
On Sat, Dec 02, 2023 at 09:50:33AM +0100, Bruno Haible wrote: > I still don't know whether it's OK to have pointers to arrays with > 0 elements (which are not "array objects", since "objects" are non- > empty (§ 6.2.6.1.(2))). From § 6.7.6.2 about array declarators: If the expression is a cons

Re: [PATCH] Update portability doc for CHERI, C23

2023-12-02 Thread Bruno Haible
Paul Eggert wrote: > > Which integer types on CHERI have "holes"? > > intptr_t and uintptr_t, since they consume 128 bits of storage but have > only 64 bits of integer value payload. Oh, indeed. I had through that intptr_t and uintptr_t support normal 128-bit integer arithmetic, but this is not

Re: undefined-behavior obstack.c:139

2023-12-02 Thread Bruno Haible
Paul Eggert wrote: > > Indeed, this sentence appears to forbid ((char *) NULL) + something. > > Yes. However, Gnulib code can still use ((char *) NULL) + something) > because the Gnulib portability guidelines allow it. > > The issue with clang false positives is covered here: > > https://www.gn

Re: undefined-behavior obstack.c:139

2023-12-02 Thread Bruno Haible
Andreas F. Borchert wrote: > In summary, null pointer constants are not pointers to an object > or an element of an array object and thereby must not be used > for pointer arithmetic. Thanks for the explanations. I still don't know whether it's OK to have pointers to arrays with 0 elements (which