public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579
@ 2021-02-10 17:06 gscfq@t-online.de
2021-02-10 18:40 ` [Bug c++/99062] " mpolacek at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: gscfq@t-online.de @ 2021-02-10 17:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
Bug ID: 99062
Summary: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: gscfq@t-online.de
Target Milestone: ---
Changed between 20190512 and 20190519 :
$ cat z1.cc
enum { a = 1 << 31 };
void *f () __attribute__ ((assume_aligned (a, 4)));
$ g++-11-20210207 -c z1.cc
z1.cc:2:50: internal compiler error: in tree_to_uhwi, at tree.h:4579
2 | void *f () __attribute__ ((assume_aligned (a, 4)));
| ^
0x8835a6 tree_to_uhwi(tree_node const*)
../../gcc/tree.h:4579
0x8835a6 handle_assume_aligned_attribute
../../gcc/c-family/c-attribs.c:3565
0x823311 decl_attributes(tree_node**, tree_node*, int, tree_node*)
../../gcc/attribs.c:724
0x6e6fc7 cplus_decl_attributes(tree_node**, tree_node*, int)
../../gcc/cp/decl2.c:1596
0x6272a2 grokfndecl
../../gcc/cp/decl.c:9983
0x6d5261 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
../../gcc/cp/decl.c:13818
0x6da5f8 start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
../../gcc/cp/decl.c:5333
0x79bffb cp_parser_init_declarator
../../gcc/cp/parser.c:21660
0x77cf3a cp_parser_simple_declaration
../../gcc/cp/parser.c:14381
0x7a0ea5 cp_parser_declaration
../../gcc/cp/parser.c:14078
0x7a03db cp_parser_translation_unit
../../gcc/cp/parser.c:4936
0x7a03db c_parse_file()
../../gcc/cp/parser.c:45179
0x86d982 c_common_parse_file()
../../gcc/c-family/c-opts.c:1218
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99062] [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
@ 2021-02-10 18:40 ` mpolacek at gcc dot gnu.org
2021-02-10 18:45 ` mpolacek at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-10 18:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org,
| |msebor at gcc dot gnu.org
Last reconfirmed| |2021-02-10
Keywords| |ice-on-valid-code
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Target Milestone|--- |10.3
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r271338.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99062] [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
2021-02-10 18:40 ` [Bug c++/99062] " mpolacek at gcc dot gnu.org
@ 2021-02-10 18:45 ` mpolacek at gcc dot gnu.org
2021-02-10 18:59 ` mpolacek at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-10 18:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Must be this part:
@@ -2935,8 +2936,8 @@ handle_assume_aligned_attribute (tree *node, tree name,
tree args, int,
/* The misalignment specified by the second argument
must be non-negative and less than the alignment. */
warning (OPT_Wattributes,
- "%qE attribute argument %E is not in the range [0, %E)",
- name, val, align);
+ "%qE attribute argument %E is not in the range [0, %wu]",
+ name, val, tree_to_uhwi (align) - 1);
*no_add_attrs = true;
return NULL_TREE;
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99062] [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
2021-02-10 18:40 ` [Bug c++/99062] " mpolacek at gcc dot gnu.org
2021-02-10 18:45 ` mpolacek at gcc dot gnu.org
@ 2021-02-10 18:59 ` mpolacek at gcc dot gnu.org
2021-02-10 20:51 ` msebor at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-10 18:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Status|NEW |ASSIGNED
Priority|P3 |P2
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
So we need to check that ALIGN is sane.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99062] [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
` (2 preceding siblings ...)
2021-02-10 18:59 ` mpolacek at gcc dot gnu.org
@ 2021-02-10 20:51 ` msebor at gcc dot gnu.org
2021-02-10 21:05 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-02-10 20:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
There already is a test in the attribute handler to validate the alignment: it
calls integer_pow2p (val). Val here is:
<integer_cst 0x7fffea7f7ed0 type <integer_type 0x7fffea8105e8 int> constant
-2147483648>
but integer_pow2p (val) returns true. I'd expect the function to return false
since INT_MIN is not a power of two. Anyway, the test integer_pow2p (val)
should probably be changed to tree_int_cst_sgn (val) < 0 || integer_pow2p
(val).
Separately, the warning should be enhanced to understand that [x, y) is a
half-open range and not complain; then the code can go back to the original [0,
%E) without any additional checking.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99062] [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
` (3 preceding siblings ...)
2021-02-10 20:51 ` msebor at gcc dot gnu.org
@ 2021-02-10 21:05 ` mpolacek at gcc dot gnu.org
2021-02-16 19:08 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-10 21:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #4)
> There already is a test in the attribute handler to validate the alignment:
> it calls integer_pow2p (val). Val here is:
> <integer_cst 0x7fffea7f7ed0 type <integer_type 0x7fffea8105e8 int>
> constant -2147483648>
> but integer_pow2p (val) returns true. I'd expect the function to return
> false since INT_MIN is not a power of two. Anyway, the test integer_pow2p
> (val) should probably be changed to tree_int_cst_sgn (val) < 0 ||
> integer_pow2p (val).
About to post a patch that hoists the tree_int_cst_sgn check so that we don't
have to repeat it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99062] [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
` (4 preceding siblings ...)
2021-02-10 21:05 ` mpolacek at gcc dot gnu.org
@ 2021-02-16 19:08 ` cvs-commit at gcc dot gnu.org
2021-02-16 19:08 ` [Bug c++/99062] [10 " mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-02-16 19:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:30a4d95bf76b0a0fdb66ac0211589a4434c83af3
commit r11-7259-g30a4d95bf76b0a0fdb66ac0211589a4434c83af3
Author: Marek Polacek <polacek@redhat.com>
Date: Wed Feb 10 15:24:25 2021 -0500
c-family: ICE with assume_aligned attribute [PR99062]
We ICE in handle_assume_aligned_attribute since r271338 which added
@@ -2935,8 +2936,8 @@ handle_assume_aligned_attribute (tree *node, tree
name, tree args, int,
/* The misalignment specified by the second argument
must be non-negative and less than the alignment. */
warning (OPT_Wattributes,
- "%qE attribute argument %E is not in the range [0, %E)",
- name, val, align);
+ "%qE attribute argument %E is not in the range [0,
%wu]",
+ name, val, tree_to_uhwi (align) - 1);
*no_add_attrs = true;
return NULL_TREE;
}
because align is INT_MIN and tree_to_uhwi asserts tree_fits_uhwi_p -- which
ALIGN does not and the prior tree_fits_shwi_p check is fine with it, as
well as the integer_pow2p check.
Since neither of the arguments to assume_aligned can be negative, I've
hoisted the tree_int_cst_sgn check. And add the missing "argument"
word to an existing warning.
gcc/c-family/ChangeLog:
PR c++/99062
* c-attribs.c (handle_assume_aligned_attribute): Check that the
alignment argument is non-negative. Tweak a warning message.
gcc/testsuite/ChangeLog:
PR c++/99062
* gcc.dg/attr-assume_aligned-4.c: Adjust dg-warning.
* g++.dg/ext/attr-assume-aligned.C: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99062] [10 Regression] ICE in tree_to_uhwi, at tree.h:4579
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
` (5 preceding siblings ...)
2021-02-16 19:08 ` cvs-commit at gcc dot gnu.org
@ 2021-02-16 19:08 ` mpolacek at gcc dot gnu.org
2021-03-29 12:38 ` cvs-commit at gcc dot gnu.org
2021-03-29 12:39 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-02-16 19:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11 Regression] ICE in |[10 Regression] ICE in
|tree_to_uhwi, at |tree_to_uhwi, at
|tree.h:4579 |tree.h:4579
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99062] [10 Regression] ICE in tree_to_uhwi, at tree.h:4579
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
` (6 preceding siblings ...)
2021-02-16 19:08 ` [Bug c++/99062] [10 " mpolacek at gcc dot gnu.org
@ 2021-03-29 12:38 ` cvs-commit at gcc dot gnu.org
2021-03-29 12:39 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-29 12:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:9d020d111fbeae228b20d75a8c832b214e561ab3
commit r10-9553-g9d020d111fbeae228b20d75a8c832b214e561ab3
Author: Marek Polacek <polacek@redhat.com>
Date: Wed Feb 10 15:24:25 2021 -0500
c-family: ICE with assume_aligned attribute [PR99062]
We ICE in handle_assume_aligned_attribute since r271338 which added
@@ -2935,8 +2936,8 @@ handle_assume_aligned_attribute (tree *node, tree
name, tree args, int,
/* The misalignment specified by the second argument
must be non-negative and less than the alignment. */
warning (OPT_Wattributes,
- "%qE attribute argument %E is not in the range [0, %E)",
- name, val, align);
+ "%qE attribute argument %E is not in the range [0,
%wu]",
+ name, val, tree_to_uhwi (align) - 1);
*no_add_attrs = true;
return NULL_TREE;
}
because align is INT_MIN and tree_to_uhwi asserts tree_fits_uhwi_p -- which
ALIGN does not and the prior tree_fits_shwi_p check is fine with it, as
well as the integer_pow2p check.
Since neither of the arguments to assume_aligned can be negative, I've
hoisted the tree_int_cst_sgn check. And add the missing "argument"
word to an existing warning.
gcc/c-family/ChangeLog:
PR c++/99062
* c-attribs.c (handle_assume_aligned_attribute): Check that the
alignment argument is non-negative. Tweak a warning message.
gcc/testsuite/ChangeLog:
PR c++/99062
* gcc.dg/attr-assume_aligned-4.c: Adjust dg-warning.
* g++.dg/ext/attr-assume-aligned.C: New test.
(cherry picked from commit 30a4d95bf76b0a0fdb66ac0211589a4434c83af3)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/99062] [10 Regression] ICE in tree_to_uhwi, at tree.h:4579
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
` (7 preceding siblings ...)
2021-03-29 12:38 ` cvs-commit at gcc dot gnu.org
@ 2021-03-29 12:39 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-03-29 12:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99062
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
Known to fail| |10.2.0
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-03-29 12:39 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 17:06 [Bug c++/99062] New: [10/11 Regression] ICE in tree_to_uhwi, at tree.h:4579 gscfq@t-online.de
2021-02-10 18:40 ` [Bug c++/99062] " mpolacek at gcc dot gnu.org
2021-02-10 18:45 ` mpolacek at gcc dot gnu.org
2021-02-10 18:59 ` mpolacek at gcc dot gnu.org
2021-02-10 20:51 ` msebor at gcc dot gnu.org
2021-02-10 21:05 ` mpolacek at gcc dot gnu.org
2021-02-16 19:08 ` cvs-commit at gcc dot gnu.org
2021-02-16 19:08 ` [Bug c++/99062] [10 " mpolacek at gcc dot gnu.org
2021-03-29 12:38 ` cvs-commit at gcc dot gnu.org
2021-03-29 12:39 ` rguenth 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).