bug-m4
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undefined-behavior obstack.c:139


From: Andreas F. Borchert
Subject: Re: undefined-behavior obstack.c:139
Date: Sat, 2 Dec 2023 18:16:02 +0100

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 constant expression, it shall have a
   value greater than zero.

Hence, arrays must have at least one element. And in case of
memory management functions, the behaviour is implementation-defined
for a requested size of zero (see § 7.24.3) and null
pointers are possible. Hence pointer arithmetic is not supported
for pointers returned by malloc(0).

Andreas

-- 
Dr. Andreas F. Borchert,  Institut für Numerische Mathematik, Universität Ulm
Helmholtzstr. 20, 89081 Ulm, +49 7315023572 https://mathematik.uni-ulm.de/afb

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]