
Hello, I was building tz with gcc-13 and noticed that without explicit -std=c2x it fails to build 2022g version with: ``` zic.c:462:1: warning: ‘noreturn’ attribute ignored [-Wattributes] 462 | static ATTRIBUTE_NORETURN void | ^~~~~~ zic.c:462:27: error: expected identifier or ‘(’ before ‘void’ 462 | static ATTRIBUTE_NORETURN void | ^~~~ ``` The last code change on github in this are was: https://github.com/eggert/tz/commit/dbfcefe0c129e36e8c5acbcedf1400c1b486d962 It builds fine for me with gcc-12 without -std: ``` __STDC_VERSION__ = 201710 __has_c_attribute(noreturn) = 0 ``` and with -std=c2x: ``` __STDC_VERSION__ = 202000 __has_c_attribute(noreturn) = 0 __STRICT_ANSI__ ``` but with gcc-13 it builds only with explicit -std=c2x: ``` __STDC_VERSION__ = 202000 __has_c_attribute(noreturn) = 202202 __STRICT_ANSI__ ``` Maybe because __has_c_attribute(noreturn) returns 202202 even when __STDC_VERSION__ doesn't accept it yet? ``` __STDC_VERSION__ = 201710 __has_c_attribute(noreturn) = 202202 ```
From https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2764.pdf it's not clear to me when exactly [[noreturn]] can be used. It says only this about the value `Drafting note: The value used for __has_c_attribute is a placeholder that is to be replaced by the editors with the year and month the proposal is accepted into the working draft.`
Is it a bug in gcc or should it be handled somehow by private.h? Thanks

On Sat, 11 Mar 2023 11:18:43 +0100, Martin Jansa via tz wrote:
I was building tz with gcc-13 and noticed that without explicit -std=c2x it fails to build 2022g version with: ``` zic.c:462:1: warning: ‘noreturn’ attribute ignored [-Wattributes] 462 | static ATTRIBUTE_NORETURN void | ^~~~~~ zic.c:462:27: error: expected identifier or ‘(’ before ‘void’ 462 | static ATTRIBUTE_NORETURN void | ^~~~ ```
Try swapping the order of ATTRIBUTE_NORETURN and "static". C23 attributes are supposed to come first (unlike gcc-style attributes) similar to C++. - todd

On Mon, Mar 13, 2023 at 9:40 PM Todd C. Miller <Todd.Miller@sudo.ws> wrote:
On Sat, 11 Mar 2023 11:18:43 +0100, Martin Jansa via tz wrote:
I was building tz with gcc-13 and noticed that without explicit -std=c2x it fails to build 2022g version with: ``` zic.c:462:1: warning: ‘noreturn’ attribute ignored [-Wattributes] 462 | static ATTRIBUTE_NORETURN void | ^~~~~~ zic.c:462:27: error: expected identifier or ‘(’ before ‘void’ 462 | static ATTRIBUTE_NORETURN void | ^~~~ ```
Try swapping the order of ATTRIBUTE_NORETURN and "static". C23 attributes are supposed to come first (unlike gcc-style attributes) similar to C++.
Thanks, you're right. And when I've started to do that instead of my work around ("if __has_c_attribute(noreturn) && 202000 <= __STDC_VERSION__") I've forked tz on github to send it as PR and discovered that it's already resolved there in version newer than 2022g I was using locally, don't know how I've overlooked that before (probably because I was looking more at private.h and less on zic.c/zdump.c). It's resolved in: https://github.com/eggert/tz/commit/9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f I'll at least backport it to OpenEmbedded now :). Regards,

On 3/11/23 02:18, Martin Jansa via tz wrote:
zic.c:462:1: warning: ‘noreturn’ attribute ignored [-Wattributes] 462 | static ATTRIBUTE_NORETURN void | ^~~~~~
That portability bug was fixed here: https://github.com/eggert/tz/commit/9cfe9507fcc22cd4a0c4da486ea1c7f0de6b075f and this fix should appear in the next release. A copy of the patch is attached; please give it a try or better yet, use bleeding-edge GitHub.

On 2023-03-11 03:18, Martin Jansa via tz wrote:
I was building tz with gcc-13 and noticed that without explicit -std=c2x it fails to build 2022g version with: ``` zic.c:462:1: warning: ‘noreturn’ attribute ignored [-Wattributes] 462 | static ATTRIBUTE_NORETURN void | ^~~~~~ zic.c:462:27: error: expected identifier or ‘(’ before ‘void’ 462 | static ATTRIBUTE_NORETURN void | ^~~~ ```
The last code change on github in this are was: https://github.com/eggert/tz/commit/dbfcefe0c129e36e8c5acbcedf1400c1b486d962 <https://github.com/eggert/tz/commit/dbfcefe0c129e36e8c5acbcedf1400c1b486d962>
It builds fine for me with gcc-12 without -std: ``` __STDC_VERSION__ = 201710 __has_c_attribute(noreturn) = 0 ``` and with -std=c2x: ``` __STDC_VERSION__ = 202000 __has_c_attribute(noreturn) = 0 __STRICT_ANSI__ ```
but with gcc-13 it builds only with explicit -std=c2x: ``` __STDC_VERSION__ = 202000 __has_c_attribute(noreturn) = 202202 __STRICT_ANSI__ ```
Maybe because __has_c_attribute(noreturn) returns 202202 even when __STDC_VERSION__ doesn't accept it yet? ``` __STDC_VERSION__ = 201710 __has_c_attribute(noreturn) = 202202 ```
From https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2764.pdf <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2764.pdf> it's not clear to me when exactly [[noreturn]] can be used. It says only this about the value `Drafting note: The value used for __has_c_attribute is a placeholder that is to be replaced by the editors with the year and month the proposal is accepted into the working draft.`
Is it a bug in gcc or should it be handled somehow by private.h? Does it build with -std=gnu2x - does it relax the order constraints?
-- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry
participants (4)
-
Brian Inglis
-
Martin Jansa
-
Paul Eggert
-
Todd C. Miller