Hello, The new tzcode uses static_assert() with no message which is a c2x extension. clang does not like that by default (without specifying -std=gnu2x). /home/source/ab/HEAD-llvm/src/lib/libc/time/private.h:1017:52: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions] || TIME_T_MAX >> (TYPE_BIT(time_t) - 2) == 1); ^ , "" Best, christos
On 2026-01-07 09:12, Christos Zoulas via tz wrote:
Hello,
The new tzcode uses static_assert() with no message which is a c2x extension. clang does not like that by default (without specifying - std=gnu2x).
/home/source/ab/HEAD-llvm/src/lib/libc/time/private.h:1017:52: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x- extensions] || TIME_T_MAX >> (TYPE_BIT(time_t) - 2) == 1); ^ , ""
Which clang? I'm not seeing that diagnostic with clang version 20.1.8 (Fedora 20.1.8-4.fc42). Also, that code appears on line 994 in upstream tzcode, whereas your diagnostic says line 1017. So I suppose you're using a modified private.h? The upstream private.h contains this: /* For pre-C23 compilers, a substitute for static_assert. Some of these compilers may warn if it is used outside the top level. */ #if __STDC_VERSION__ < 202311 && !defined static_assert # define static_assert(cond) extern int static_assert_check[(cond) ? 1 : -1] #endif so you might use 'clang -E' to see why that isn't working for you as it should.
On 2026-01-07 12:58 pm, Paul Eggert wrote:
On 2026-01-07 09:12, Christos Zoulas via tz wrote:
Hello,
The new tzcode uses static_assert() with no message which is a c2x extension. clang does not like that by default (without specifying - std=gnu2x).
/home/source/ab/HEAD-llvm/src/lib/libc/time/private.h:1017:52: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x- extensions] || TIME_T_MAX >> (TYPE_BIT(time_t) - 2) == 1); ^ , ""
Which clang? I'm not seeing that diagnostic with clang version 20.1.8 (Fedora 20.1.8-4.fc42).
clang-19.1.7
Also, that code appears on line 994 in upstream tzcode, whereas your diagnostic says line 1017. So I suppose you're using a modified private.h? The upstream private.h contains this:
Yes, it is slightly modified, but not in a way to affect this.
/* For pre-C23 compilers, a substitute for static_assert.
Some of these compilers may warn if it is used outside the top level. */ #if __STDC_VERSION__ < 202311 && !defined static_assert # define static_assert(cond) extern int static_assert_check[(cond) ? 1 : -1] #endif
so you might use 'clang -E' to see why that isn't working for you as it should.
The problem is that the static_assert macro is defined for pre-2023 compilers. It has been present in stdc11 and stdc17 IIRC. What is new in stdc2023, is that the message can be optional. I.e. prior to std2023, you needed static_assert(cond, message), with 2023 you can have static_assert(cond). This is what clang is complaining about when I am building using -std=gnu11: the missing message which was made optional in stdc2023. christos
Christos Zoulas via tz wrote in <def4711934751d2fb6d05c1a63fa5311@zoulas.com>: |On 2026-01-07 12:58 pm, Paul Eggert wrote: |> On 2026-01-07 09:12, Christos Zoulas via tz wrote: |>> Hello, |>> |>> The new tzcode uses static_assert() with no message which is a c2x |>> extension. clang does not like that by default (without specifying - |>> std=gnu2x). ... |> Which clang? I'm not seeing that diagnostic with clang version 20.1.8 |> (Fedora 20.1.8-4.fc42). | |clang-19.1.7 ... |The problem is that the static_assert macro is defined for pre-2023 |compilers. And in a totally borked way that noone can use! They should have used the C++ variant, but instead they have chosen to create some unusable borked thing -- it is not only what you say next, oh no! |It has been present in stdc11 and stdc17 IIRC. What is new in stdc2023, |is that the message can be optional. |I.e. prior to std2023, you needed static_assert(cond, message), with |2023 you can have static_assert(cond). |This is what clang is complaining about when I am building using |-std=gnu11: the missing message which |was made optional in stdc2023. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)
On 1/7/26 10:58, Christos Zoulas wrote:
On 2026-01-07 12:58 pm, Paul Eggert wrote:
Also, that code appears on line 994 in upstream tzcode, whereas your diagnostic says line 1017. So I suppose you're using a modified private.h? The upstream private.h contains this:
Yes, it is slightly modified, but not in a way to affect this.
I looked at NetBSD trunk on GitHub, and I think I see the problem. NetBSD's copy of localtime.c differs from upstream by including <assert.h>, for no reason. To fix the problem, remove that "#include <assert.h>" line. That line was added to NetBSD's lib/libc/time/localtime.c in 2013 (commit 33d9f9e08d3535053feb424293a0e5a0f9b39650) for reasons that are no longer relevant (a _DIAGASSERT was added then but is no longer present).
The problem is that the static_assert macro is defined for pre-2023 compilers.
Yes, but on those platforms the static_assert macro is defined only by <assert.h>, as per the relevant ISO C and POSIX standards. Since tzcode never includes <assert.h> it should not run into the problem.
participants (3)
-
Christos Zoulas -
Paul Eggert -
Steffen Nurpmeso