public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99032] New: GCC accepts attributes on friend declarations (not definitions)
@ 2021-02-09 17:39 dangelog at gmail dot com
  2021-02-09 17:44 ` [Bug c++/99032] " mpolacek at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dangelog at gmail dot com @ 2021-02-09 17:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99032
           Summary: GCC accepts attributes on friend declarations (not
                    definitions)
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dangelog at gmail dot com
  Target Milestone: ---

Hi,

The following code is accepted by GCC 10.2:

  struct S { [[deprecated]] friend void f(); };

No errors and no warnings are generated under -Wall -Wextra -pedantic.

The code is however ill-formed: an attribute cannot appear on a friend 
declaration which isn't also a definition:

https://eel.is/c++draft/dcl.attr#grammar-5.sentence-3

    If an attribute-specifier-seq appertains to a friend declaration
([class.friend]), that declaration shall be a definition.


For comparison, Clang rejects this, and MSVC accepts it (without warnings).

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

end of thread, other threads:[~2021-05-14  1:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09 17:39 [Bug c++/99032] New: GCC accepts attributes on friend declarations (not definitions) dangelog at gmail dot com
2021-02-09 17:44 ` [Bug c++/99032] " mpolacek at gcc dot gnu.org
2021-05-11 20:04 ` mpolacek at gcc dot gnu.org
2021-05-14  1:13 ` cvs-commit at gcc dot gnu.org
2021-05-14  1:14 ` mpolacek 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).