bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 12/14] doc: mention Solaris malloc ENOMEM issues


From: Bruno Haible
Subject: Re: [PATCH 12/14] doc: mention Solaris malloc ENOMEM issues
Date: Tue, 05 Nov 2024 16:40:13 +0100

Paul Eggert wrote:
> diff --git a/doc/posix-functions/malloc.texi b/doc/posix-functions/malloc.texi
> index 31e199e43a..6a6f3c1059 100644
> --- a/doc/posix-functions/malloc.texi
> +++ b/doc/posix-functions/malloc.texi
> @@ -12,7 +12,7 @@ Portability problems fixed by Gnulib:
>  @item
>  Upon failure, the function does not set @code{errno} to @code{ENOMEM} on
>  some platforms:
> -mingw, MSVC 14.
> +mingw, MSVC 14, Solaris 11.4.

Huh? Solaris is not known for blatant POSIX violations, and the unit test
that I added in tests/test-malloc-posix.c on 2024-10-31 passed on Solaris 11.4
(with gcc).

What did your test program look like? Are you sure you didn't encounter
the clang bug <https://github.com/llvm/llvm-project/issues/114772> ?

My test program
========================================================
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
int main () {
  void * volatile p;

  errno = 0;
  p = malloc (SIZE_MAX / 2 + 10);
  printf ("p = %p, errno = %d\n", p, errno);

  errno = 0;
  p = malloc (SIZE_MAX / 10);
  printf ("p = %p, errno = %d\n", p, errno);

  errno = 0;
  p = malloc (SIZE_MAX / 100);
  printf ("p = %p, errno = %d\n", p, errno);

  errno = 0;
  p = malloc (SIZE_MAX / 1000);
  printf ("p = %p, errno = %d\n", p, errno);
}
=========================================================

prints this on Solaris 11.4:

p = 0, errno = 12
p = 0, errno = 12
p = 0, errno = 12
p = 0, errno = 12

Bruno






reply via email to

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