From 074fa78f5e5178bc18355bacaa3fd5bfe42c602c Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Thu, 15 Sep 2022 13:56:38 +0200 Subject: [PATCH] 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. --- lib/tests/posix/50-open-read.c | 7 ++++++- lib/tests/scaffold/7i-struct-struct.c | 9 +++++++-- lib/tests/scaffold/t.c | 7 ++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/tests/posix/50-open-read.c b/lib/tests/posix/50-open-read.c index 3b901d2b..52dcc4d3 100644 --- a/lib/tests/posix/50-open-read.c +++ b/lib/tests/posix/50-open-read.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2019, 2022 Jan (janneke) Nieuwenhuizen * * 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 = "."; diff --git a/lib/tests/scaffold/7i-struct-struct.c b/lib/tests/scaffold/7i-struct-struct.c index 381bce90..45f55aee 100644 --- a/lib/tests/scaffold/7i-struct-struct.c +++ b/lib/tests/scaffold/7i-struct-struct.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2022 Jan (janneke) Nieuwenhuizen * * 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)); diff --git a/lib/tests/scaffold/t.c b/lib/tests/scaffold/t.c index 42b4e802..b00b17bf 100644 --- a/lib/tests/scaffold/t.c +++ b/lib/tests/scaffold/t.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen * * 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: ");