public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/112339] ICE with clang::no_sanitize and -fsanitize=
Date: Tue, 05 Dec 2023 16:32:30 +0000	[thread overview]
Message-ID: <bug-112339-4-j0BymheLqH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112339-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:ef88041a578644b8e4f964903b2fbbcf0f1d7ce8

commit r13-8120-gef88041a578644b8e4f964903b2fbbcf0f1d7ce8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Nov 9 09:05:54 2023 +0100

    attribs: Fix ICE with -Wno-attributes= [PR112339]

    The following testcase ICEs, because with -Wno-attributes=foo::no_sanitize
    (but generally any other non-gnu namespace and some gnu well known
attribute
    name within that other namespace) the FEs don't really parse attribute
    arguments of such attribute, but lookup_attribute_spec is non-NULL with
    NULL handler and such attributes are added to DECL_ATTRIBUTES or
    TYPE_ATTRIBUTES and then when e.g. middle-end does lookup_attribute
    on a particular attribute and expects the attribute to mean something
    and/or have a particular verified arguments, it can crash when seeing
    the foreign attribute in there instead.

    The following patch fixes that by never adding ignored attributes
    to DECL_ATTRIBUTES/TYPE_ATTRIBUTES, previously that was the case just
    for attributes in ignored namespace (where lookup_attribute_space
    returned NULL).  We don't really know anything about those attributes,
    so shouldn't pretend we know something about them, especially when
    the arguments are error_mark_node or NULL instead of something that
    would have been parsed.  And it would be really weird if we normally
    ignore say [[clang::unused]] attribute, but when people use
    -Wno-attributes=clang::unused we actually treated it as gnu::unused.
    All the user asked for is suppress warnings about that attribute being
    unknown.

    The first hunk is just playing safe, I'm worried people could
    -Wno-attributes=gnu::
    and get various crashes with known GNU attributes not being actually
    parsed and recorded (or worse e.g. when we tweak standard attributes
    into GNU attributes and we wouldn't add those).
    The -Wno-attributes= documentation says that it suppresses warning about
    unknown attributes, so I think -Wno-attributes=gnu:: should prevent
    warning about say [[gnu::foobarbaz]] attribute, but not about
    [[gnu::unused]] because the latter is a known attribute.
    The routine would return true for any scoped attribute in the ignored
    namespace, with the change it ignores only unknown attributes in ignored
    namespace, known ones in there will be ignored only if they have
    max_length of -2 (e.g.. with
    -Wno-attributes=gnu:: -Wno-attributes=gnu::foobarbaz).

    2023-11-09  Jakub Jelinek  <jakub@redhat.com>

            PR c/112339
            * attribs.cc (attribute_ignored_p): Only return true for
            attr_namespace_ignored_p if as is NULL.
            (decl_attributes): Never add ignored attributes.

            * c-c++-common/ubsan/Wno-attributes-1.c: New test.

    (cherry picked from commit 533241c6c60bc7c9f7dc47a94e94b5eed1b370e6)

  parent reply	other threads:[~2023-12-05 16:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 18:37 [Bug c++/112339] New: ICE with namespaced attribute on function s_gccbugzilla at nedprod dot com
2023-11-01 18:45 ` [Bug sanitizer/112339] ICE with clang::no_sanitize and -fsanitize= pinskia at gcc dot gnu.org
2023-11-02  9:45 ` [Bug c/112339] " jakub at gcc dot gnu.org
2023-11-08 22:32 ` s_gccbugzilla at nedprod dot com
2023-11-09  8:07 ` cvs-commit at gcc dot gnu.org
2023-12-05 16:32 ` cvs-commit at gcc dot gnu.org [this message]
2023-12-16  0:37 ` cvs-commit at gcc dot gnu.org
2023-12-16  8:46 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-112339-4-j0BymheLqH@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).