From b98f243e7921ddff6978ee9b0ce9f08efaa17951 Mon Sep 17 00:00:00 2001 From: "Alex Xu (Hello71)" Date: Sun, 2 Jul 2023 20:29:41 -0400 Subject: [PATCH 2/4] __year_to_secs: fix dangling pointer C11 6.5.2.5p5: > If the compound literal occurs outside the body of a function, the > object has static storage duration; otherwise, it has automatic > storage duration associated with the enclosing block. gcc also warns about this. --- src/time/__year_to_secs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/time/__year_to_secs.c b/src/time/__year_to_secs.c index 2824ec6d..d215880a 100644 --- a/src/time/__year_to_secs.c +++ b/src/time/__year_to_secs.c @@ -10,9 +10,9 @@ long long __year_to_secs(long long year, int *is_leap) return 31536000*(y-70) + 86400*leaps; } - int cycles, centuries, leaps, rem; + int cycles, centuries, leaps, rem, tmp; - if (!is_leap) is_leap = &(int){0}; + if (!is_leap) is_leap = &tmp; cycles = (year-100) / 400; rem = (year-100) % 400; if (rem < 0) { -- 2.41.0