DRAFT lib/test: Cater for gcc-12.2.0.

These inexplicably avoid segfaults with gcc-12.2.0.

* lib/tests/posix/50-open-read.c (main)[__GNUC__ > 11]: Use malloc
instead of local allocated string.
* lib/tests/scaffold/7i-struct-struct.c (main)[__GNUC__ > 11]:
Initialize all fields of struct.
* lib/tests/scaffold/t.c (main): Likewise.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2022-09-15 13:56:38 +02:00
parent a64e292ce2
commit 015e68a28a
3 changed files with 19 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2019, 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -29,7 +29,12 @@ int
main (int argc, char const *argv[])
{
eputs ("test:getenv\n");
#if __GNUC__ > 11
char* file_name = malloc (PATH_MAX);
#else
// FIXME: gcc-12.2.0 fails open using this
char file_name[PATH_MAX];
#endif
char *srcdir = getenv ("abs_top_srcdir");
if (! srcdir) // for running by hand
srcdir = ".";

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2017,2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -48,7 +48,12 @@ struct anon
int
main ()
{
struct foo f = { 0, 1, 2 };
#if __GNUC__ > 11
struct foo f = { 0, 1, 2, 0, 0 };
#else
// FIXME: gcc-12.2.0 segfaults on this
struct foo f = { 0, 1, 2, 0 };
#endif
f.s.baz = 2;
oputs ("f.s.bar=");
oputs (itoa (f.s.bar));

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
@ -214,7 +214,12 @@ main (int argc, char *argv[])
//i = (*fun2)(argc, argv);
i = 1;
#if __GNUC__ > 11
int lst[6] = { -1, 1 - 1, i, 2, 3, 0 };
#else
// FIXME: gcc-12.2.0 segfaults on this
int lst[6] = { -1, 1 - 1, i, 2, 3 };
#endif
for (int i = 0; i < 4; i++)
{
eputs ("i: ");