public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103365] New: [12 Regression] ICE in register_scoped_attribute, at attribs.c:390
@ 2021-11-22 19:37 gscfq@t-online.de
  2021-11-22 21:14 ` [Bug middle-end/103365] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gscfq@t-online.de @ 2021-11-22 19:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103365
           Summary: [12 Regression] ICE in register_scoped_attribute, at
                    attribs.c:390
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Started between 20211107 and 20211114  :


$ cat z1.c
#pragma GCC diagnostic ignored_attributes "c1::_attr"


$ gcc-12-20211121 -c z1.c
z1.c:1:9: internal compiler error: in register_scoped_attribute, at
attribs.c:390
    1 | #pragma GCC diagnostic ignored_attributes "c1::_attr"
      |         ^~~
0x74a559 register_scoped_attribute
        ../../gcc/attribs.c:390
0x74a640 register_scoped_attributes(attribute_spec const*, char const*, bool)
        ../../gcc/attribs.c:164
0x74acbd handle_ignored_attributes_option(vec<char*, va_heap, vl_ptr>*)
        ../../gcc/attribs.c:315
0x80bd84 handle_pragma_diagnostic
        ../../gcc/c-family/c-pragma.c:826
0x791881 c_parser_pragma
        ../../gcc/c/c-parser.c:12616
0x7b7135 c_parser_external_declaration
        ../../gcc/c/c-parser.c:1761
0x7b79fb c_parser_translation_unit
        ../../gcc/c/c-parser.c:1653
0x7b79fb c_parse_file()
        ../../gcc/c/c-parser.c:23280
0x808eb2 c_common_parse_file()
        ../../gcc/c-family/c-opts.c:1240

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

* [Bug middle-end/103365] ICE in register_scoped_attribute, at attribs.c:390
  2021-11-22 19:37 [Bug c/103365] New: [12 Regression] ICE in register_scoped_attribute, at attribs.c:390 gscfq@t-online.de
@ 2021-11-22 21:14 ` pinskia at gcc dot gnu.org
  2021-11-23  7:54 ` [Bug middle-end/103365] ICE in register_scoped_attribute, with attribute starting with underscore: -Wno-attributes=n::_a or #pragma GCC diagnostic ignored_attributes "n::_a" marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-22 21:14 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12 Regression] ICE in      |ICE in
                   |register_scoped_attribute,  |register_scoped_attribute,
                   |at attribs.c:390            |at attribs.c:390
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-on-valid-code
   Last reconfirmed|                            |2021-11-22
     Ever confirmed|0                           |1
          Component|c                           |middle-end

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
#pragma GCC diagnostic ignored_attributes "n::_a"

There is a check to make sure the attribute isn't named __a__ but the assert
only checks that the attribute starts with _.

Note you can also reproduce the ICE with the following option passed to GCC:
-Wno-attributes=n::_a

Confirmed, not a regression as the warning option is new.

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

* [Bug middle-end/103365] ICE in register_scoped_attribute, with attribute starting with underscore: -Wno-attributes=n::_a or #pragma GCC diagnostic ignored_attributes "n::_a"
  2021-11-22 19:37 [Bug c/103365] New: [12 Regression] ICE in register_scoped_attribute, at attribs.c:390 gscfq@t-online.de
  2021-11-22 21:14 ` [Bug middle-end/103365] " pinskia at gcc dot gnu.org
@ 2021-11-23  7:54 ` marxin at gcc dot gnu.org
  2021-11-23 14:13 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-11-23  7:54 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r12-5123-ga1ad0d84d7fcbcaa.

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

* [Bug middle-end/103365] ICE in register_scoped_attribute, with attribute starting with underscore: -Wno-attributes=n::_a or #pragma GCC diagnostic ignored_attributes "n::_a"
  2021-11-22 19:37 [Bug c/103365] New: [12 Regression] ICE in register_scoped_attribute, at attribs.c:390 gscfq@t-online.de
  2021-11-22 21:14 ` [Bug middle-end/103365] " pinskia at gcc dot gnu.org
  2021-11-23  7:54 ` [Bug middle-end/103365] ICE in register_scoped_attribute, with attribute starting with underscore: -Wno-attributes=n::_a or #pragma GCC diagnostic ignored_attributes "n::_a" marxin at gcc dot gnu.org
@ 2021-11-23 14:13 ` jakub at gcc dot gnu.org
  2021-11-23 14:14 ` [Bug middle-end/103365] [12 Regression] " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-23 14:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 51860
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51860&action=edit
gcc12-pr103365.patch

Untested fix.

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

* [Bug middle-end/103365] [12 Regression] ICE in register_scoped_attribute, with attribute starting with underscore: -Wno-attributes=n::_a or #pragma GCC diagnostic ignored_attributes "n::_a"
  2021-11-22 19:37 [Bug c/103365] New: [12 Regression] ICE in register_scoped_attribute, at attribs.c:390 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-11-23 14:13 ` jakub at gcc dot gnu.org
@ 2021-11-23 14:14 ` jakub at gcc dot gnu.org
  2021-11-24  9:09 ` cvs-commit at gcc dot gnu.org
  2021-11-24  9:11 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-23 14:14 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
           Priority|P3                          |P1
            Summary|ICE in                      |[12 Regression] ICE in
                   |register_scoped_attribute,  |register_scoped_attribute,
                   |with attribute starting     |with attribute starting
                   |with underscore:            |with underscore:
                   |-Wno-attributes=n::_a or    |-Wno-attributes=n::_a or
                   |#pragma GCC diagnostic      |#pragma GCC diagnostic
                   |ignored_attributes "n::_a"  |ignored_attributes "n::_a"

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

* [Bug middle-end/103365] [12 Regression] ICE in register_scoped_attribute, with attribute starting with underscore: -Wno-attributes=n::_a or #pragma GCC diagnostic ignored_attributes "n::_a"
  2021-11-22 19:37 [Bug c/103365] New: [12 Regression] ICE in register_scoped_attribute, at attribs.c:390 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2021-11-23 14:14 ` [Bug middle-end/103365] [12 Regression] " jakub at gcc dot gnu.org
@ 2021-11-24  9:09 ` cvs-commit at gcc dot gnu.org
  2021-11-24  9:11 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-24  9:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:709716b9f49f2fcf46f319000562cf6e61bd2f71

commit r12-5493-g709716b9f49f2fcf46f319000562cf6e61bd2f71
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Nov 24 10:08:35 2021 +0100

    attribs: Fix ICEs on attributes starting with _ [PR103365]

    As the patch shows, we have quite a few asserts that we don't call
    lookup_attribute etc. with attr_name that starts with an underscore,
    to make sure nobody is trying to call it with non-canonicalized
    attribute name like "__cold__" instead of "cold".
    We canonicalize only attributes that start with 2 underscores and end
    with 2 underscores though.
    Before Marek's patch, that wasn't an issue, we had no attributes like
    "_foo" or "__bar_" etc., so lookup_scoped_attribute_spec would
    always return NULL for those and we wouldn't try to register them,
    look them up etc., just with -Wattributes would warn about them.
    But now, as the new testcases show, users can actually request such
    attributes to be ignored, and we ICE for those during
    register_scoped_attribute and when that is fixed, ICE later on when
    somebody uses those attributes because they will be looked up
    to find out that they should be ignored.

    So, the following patch instead of or in addition to, depending on
    how performance sensitive a particular spot is, checking that
    attribute doesn't start with underscore allows attribute
    names that start with underscore as long as it doesn't canonicalize
    (i.e. doesn't start and end with 2 underscores).
    In addition to that, I've noticed lookup_attribute_by_prefix
    was calling get_attribute_name twice unnecessarily, and 2 tests
    were running in c++98 mode with -std=c++98 -std=c++11 which IMHO
    isn't useful because -std=c++11 testing is done too when testing
    all language versions.

    2021-11-24  Jakub Jelinek  <jakub@redhat.com>

            PR middle-end/103365
            * attribs.h (lookup_attribute): Allow attr_name to start with
            underscore, as long as canonicalize_attr_name returns false.
            (lookup_attribute_by_prefix): Don't call get_attribute_name twice.
            * attribs.c (extract_attribute_substring): Reimplement using
            canonicalize_attr_name.
            (register_scoped_attribute): Change gcc_assert into
            gcc_checking_assert, verify !canonicalize_attr_name rather than
            that str.str doesn't start with '_'.

            * c-c++-common/Wno-attributes-1.c: Require effective target
            c || c++11 and drop dg-additional-options.
            * c-c++-common/Wno-attributes-2.c: Likewise.
            * c-c++-common/Wno-attributes-4.c: New test.
            * c-c++-common/Wno-attributes-5.c: New test.

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

* [Bug middle-end/103365] [12 Regression] ICE in register_scoped_attribute, with attribute starting with underscore: -Wno-attributes=n::_a or #pragma GCC diagnostic ignored_attributes "n::_a"
  2021-11-22 19:37 [Bug c/103365] New: [12 Regression] ICE in register_scoped_attribute, at attribs.c:390 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2021-11-24  9:09 ` cvs-commit at gcc dot gnu.org
@ 2021-11-24  9:11 ` jakub at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-11-24  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-11-24  9:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 19:37 [Bug c/103365] New: [12 Regression] ICE in register_scoped_attribute, at attribs.c:390 gscfq@t-online.de
2021-11-22 21:14 ` [Bug middle-end/103365] " pinskia at gcc dot gnu.org
2021-11-23  7:54 ` [Bug middle-end/103365] ICE in register_scoped_attribute, with attribute starting with underscore: -Wno-attributes=n::_a or #pragma GCC diagnostic ignored_attributes "n::_a" marxin at gcc dot gnu.org
2021-11-23 14:13 ` jakub at gcc dot gnu.org
2021-11-23 14:14 ` [Bug middle-end/103365] [12 Regression] " jakub at gcc dot gnu.org
2021-11-24  9:09 ` cvs-commit at gcc dot gnu.org
2021-11-24  9:11 ` jakub 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).