* [PATCH v2] lib/posixtm.c: Fixe build error with clang-18
@ 2024-01-16 23:38 Khem Raj
2024-01-17 1:25 ` Paul Eggert
0 siblings, 1 reply; 3+ messages in thread
From: Khem Raj @ 2024-01-16 23:38 UTC (permalink / raw)
To: bug-gnulib, bruno; +Cc: Khem Raj
Clang-18 detects this and flags it as error
x86_64-yoe-linux-clang -target x86_64-yoe-linux -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -mlittle-endian --dyld-prefix=/usr -Qunused-arguments -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/coreutils/9.4/recipe-sysroot -I. -I../coreutils-9.4 -I./lib -Ilib -I../coreutils-9.4/lib -Isrc -I../coreutils-9.4/src -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/coreutils/9.4/coreutils-9.4=/usr/src/debug/coreutils/9.4 -fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/coreutils/9.4/coreutils-9.4=/usr/src/debug/coreutils/9.4 -fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/coreutils/9.4/build=/usr/src/debug/coreutils/9.4 -fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/coreutils/9.4/build=/usr/src/debug/coreutils/9.4 -fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/coreutils/9.4/recipe-sysroot= -fmacro-prefix-map=/mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/coreutils/9.4/recipe-sysroot= -fdebug-prefix-map=/mnt/b/yoe/master/build/tmp/work/core2-64-yoe-linux/coreutils/9.4/recipe-sysroot-native= -c -o lib/libcoreutils_a-posixtm.o `test -f 'lib/posixtm.c'
lib/posixtm.c:194:15: error: operand argument to checked integer operation must be an integer type other than plain 'char', 'bool', bit-precise, or an enumeration ('bool' invalid)
194 | if (ckd_add (&t, t, leapsec))
| ^~~~~~~~~~~~~~~~~~~~~~~~
usr/lib/clang/18/include/stdckdint.h:37:54: note: expanded from macro 'ckd_add'
37 | #define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))
| ^~~
1 error generated.
* lib/posixtm.c (posixtime): Fix operand argument to checked
integer operation.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
ChangeLog | 5 +++++
lib/posixtm.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index e42d2c31ab..daca27a917 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-01-15 Khem Raj <raj.khem@gmail.com>
+
+ * lib/posixtm.c (posixtime): Fix operand argument to checked
+ integer operation.
+
2024-01-07 Jim Meyering <meyering@meta.com>
update-copyright: handle more cases
diff --git a/lib/posixtm.c b/lib/posixtm.c
index ef9f55f873..23397a6672 100644
--- a/lib/posixtm.c
+++ b/lib/posixtm.c
@@ -159,7 +159,7 @@ bool
posixtime (time_t *p, const char *s, unsigned int syntax_bits)
{
struct tm tm0;
- bool leapsec = false;
+ int leapsec = 0;
if (! posix_time_parse (&tm0, s, syntax_bits))
return false;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] lib/posixtm.c: Fixe build error with clang-18
2024-01-16 23:38 [PATCH v2] lib/posixtm.c: Fixe build error with clang-18 Khem Raj
@ 2024-01-17 1:25 ` Paul Eggert
2024-01-17 1:39 ` Khem Raj
0 siblings, 1 reply; 3+ messages in thread
From: Paul Eggert @ 2024-01-17 1:25 UTC (permalink / raw)
To: Khem Raj; +Cc: Gnulib bugs
[-- Attachment #1: Type: text/plain, Size: 113 bytes --]
Thanks, I installed the attached simpler (1-byte!) fix. Please give it a
try, as I lack easy access to clang 18.
[-- Attachment #2: 0001-posixtm-pacify-clang-18.patch --]
[-- Type: text/x-patch, Size: 1795 bytes --]
From 67c298c36f69b6906840b7584be06b7b5f33f829 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 16 Jan 2024 17:21:08 -0800
Subject: [PATCH] posixtm: pacify clang 18
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem reported by Khem Raj in:
https://lists.gnu.org/r/bug-gnulib/2024-01/msg00045.html
* lib/posixtm.c (posixtime): Pacify clang 18 by converting bool to int.
Arguably this is a bug in draft C2x, since the non-pointer args to
ckd_add should promote just like any other expressions do;
but that’s not clang’s fault.
---
ChangeLog | 10 ++++++++++
lib/posixtm.c | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index e42d2c31ab..8551538ee8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-01-16 Paul Eggert <eggert@cs.ucla.edu>
+
+ posixtm: pacify clang 18
+ Problem reported by Khem Raj in:
+ https://lists.gnu.org/r/bug-gnulib/2024-01/msg00045.html
+ * lib/posixtm.c (posixtime): Pacify clang 18 by converting bool to int.
+ Arguably this is a bug in draft C2x, since the non-pointer args to
+ ckd_add should promote just like any other expressions do;
+ but that’s not clang’s fault.
+
2024-01-07 Jim Meyering <meyering@meta.com>
update-copyright: handle more cases
diff --git a/lib/posixtm.c b/lib/posixtm.c
index ef9f55f873..a072c7cad0 100644
--- a/lib/posixtm.c
+++ b/lib/posixtm.c
@@ -191,7 +191,7 @@ posixtime (time_t *p, const char *s, unsigned int syntax_bits)
| (tm0.tm_min ^ tm1.tm_min)
| (tm0.tm_sec ^ tm1.tm_sec)))
{
- if (ckd_add (&t, t, leapsec))
+ if (ckd_add (&t, t, +leapsec))
return false;
*p = t;
return true;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] lib/posixtm.c: Fixe build error with clang-18
2024-01-17 1:25 ` Paul Eggert
@ 2024-01-17 1:39 ` Khem Raj
0 siblings, 0 replies; 3+ messages in thread
From: Khem Raj @ 2024-01-17 1:39 UTC (permalink / raw)
To: Paul Eggert; +Cc: Gnulib bugs
On Tue, Jan 16, 2024 at 5:25 PM Paul Eggert <eggert@cs.ucla.edu> wrote:
>
> Thanks, I installed the attached simpler (1-byte!) fix. Please give it a
> try, as I lack easy access to clang 18.
Ah cool!. This works for me too.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-17 1:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-16 23:38 [PATCH v2] lib/posixtm.c: Fixe build error with clang-18 Khem Raj
2024-01-17 1:25 ` Paul Eggert
2024-01-17 1:39 ` Khem Raj
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).