public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/108796] New: GCC 13 accepts [[noreturn]] attribute without -std=c2x
@ 2023-02-15  3:07 sam at gentoo dot org
  2023-02-15  3:10 ` [Bug c/108796] " sam at gentoo dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: sam at gentoo dot org @ 2023-02-15  3:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796

            Bug ID: 108796
           Summary: GCC 13 accepts [[noreturn]] attribute without -std=c2x
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sam at gentoo dot org
  Target Milestone: ---

Created attachment 54462
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54462&action=edit
foo.i

GCC 13 (13.0.1 20230212) seems to accept [[noreturn]] as an attribute even when
not in C2x mode. This leads to a build failure with sudo-1.9.13
(https://github.com/sudo-project/sudo/issues/239) since
https://github.com/sudo-project/sudo/commit/e707ffe58b3ccfe5c72f54c38eac1d7069d5021e.

Clang 16.0.0_rc2 does not accept it unless passing -std=c2x.

Is this intentional or not? Thanks.

foo.c:
```
#include <stdlib.h>

[[noreturn]] void foo(void) {
        abort();
}

int main() {
        foo();
}
```

```
$ gcc-13 --version
gcc-13 (Gentoo Hardened 13.0.1_pre20230212 p8) 13.0.1 20230212 (experimental)
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc-13 -std=c2x -O2 /tmp/foo.c # fine
$ gcc-13 -std=c99 -O2 /tmp/foo.c # fine
$ gcc-13 -O2 /tmp/foo.c -o /tmp/foo # fine

$ clang-16 --version
clang version 16.0.0 # actually 16.0.0_rc2
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm/16/bin
Configuration file: /etc/clang/clang.cfg

$ clang-16 -O2 /tmp/foo.c -o /tmp/foo
/tmp/foo.c:3:2: error: expected expression
[[noreturn]] void foo(void) {
 ^
/tmp/foo.c:3:14: error: expected identifier or '('
[[noreturn]] void foo(void) {
             ^
/tmp/foo.c:8:2: error: call to undeclared function 'foo'; ISO C99 and later do
not support implicit function declarations [-Wimplicit-function-declaration]
        foo();
        ^
3 errors generated.

$ clang-16 -std=c2x -O2 /tmp/foo.c -o /tmp/foo # fine
```

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-01-14 10:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15  3:07 [Bug c/108796] New: GCC 13 accepts [[noreturn]] attribute without -std=c2x sam at gentoo dot org
2023-02-15  3:10 ` [Bug c/108796] " sam at gentoo dot org
2023-02-15  3:11 ` sam at gentoo dot org
2023-02-15  3:44 ` sam at gentoo dot org
2023-02-15  3:46 ` pinskia at gcc dot gnu.org
2023-02-15  3:47 ` [Bug c/108796] Can't intermix C2x and GNU style attributes pinskia at gcc dot gnu.org
2023-02-15 21:02 ` joseph at codesourcery dot com
2023-02-16 13:14 ` aaron at aaronballman dot com
2023-02-16 19:20 ` joseph at codesourcery dot com
2023-02-16 20:06 ` aaron at aaronballman dot com
2023-02-16 22:34 ` aaron at aaronballman dot com
2024-01-14 10:26 ` pinskia at gcc dot gnu.org

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).