public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/111811] New: gcc: internal compiler error: tree check: expected none of vector_type, have vector_type in finish_struct
@ 2023-10-14 17:09 congli at smail dot nju.edu.cn
2023-11-12 22:09 ` [Bug c/111811] [14 Regression] ICE with vector float bitfield after error pinskia at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: congli at smail dot nju.edu.cn @ 2023-10-14 17:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
Bug ID: 111811
Summary: gcc: internal compiler error: tree check: expected
none of vector_type, have vector_type in finish_struct
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: congli at smail dot nju.edu.cn
Target Milestone: ---
Compiler explorer: https://godbolt.org/z/WWzcPWcqs.
The following program `small.c` triggers a crash in gcc-14:
``` sh
% cat small.c
struct A {
__attribute__((__vector_size__(4))) float d : 1;
};
% gcc-tk -O0 small.c
<source>:2:47: error: bit-field 'd' has invalid type
2 | __attribute__((__vector_size__(4))) float d : 1;
| ^
<source>:3:1: internal compiler error: tree check: expected none of
vector_type, have vector_type in finish_struct, at c/c-decl.cc:9358
3 | };
| ^
0x22ff3ee internal_error(char const*, ...)
???:0
0x8a7b87 tree_not_check_failed(tree_node const*, char const*, int, char const*,
...)
???:0
0xa7ab0d c_parser_declspecs(c_parser*, c_declspecs*, bool, bool, bool, bool,
bool, bool, bool, c_lookahead_kind)
???:0
0xaa468d c_parse_file()
???:0
0xb17919 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```
GCC version:
```
gcc
(Compiler-Explorer-Build-gcc-300d7d3a8f4b53d045ce43f1ed4e10301781c786-binutils-2.40)
14.0.0 20231014 (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.
```
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111811] [14 Regression] ICE with vector float bitfield after error
2023-10-14 17:09 [Bug c/111811] New: gcc: internal compiler error: tree check: expected none of vector_type, have vector_type in finish_struct congli at smail dot nju.edu.cn
@ 2023-11-12 22:09 ` pinskia at gcc dot gnu.org
2023-11-12 22:13 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-12 22:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-11-12
Summary|ICE with vector float |[14 Regression] ICE with
|bitfield after error |vector float bitfield after
| |error
CC| |pinskia at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
Target Milestone|--- |14.0
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
if (TREE_CODE (field) == FIELD_DECL
&& DECL_INITIAL (field)
&& TREE_TYPE (field) != error_mark_node)
{
unsigned HOST_WIDE_INT width
= tree_to_uhwi (DECL_INITIAL (field));
tree type = TREE_TYPE (field);
if (width != TYPE_PRECISION (type)) <--- Crash
{
Obvious introduced by the TYPE_PRECISION change to ICE on vector types:
r14-2150-gfe48f2651334bc
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111811] [14 Regression] ICE with vector float bitfield after error
2023-10-14 17:09 [Bug c/111811] New: gcc: internal compiler error: tree check: expected none of vector_type, have vector_type in finish_struct congli at smail dot nju.edu.cn
2023-11-12 22:09 ` [Bug c/111811] [14 Regression] ICE with vector float bitfield after error pinskia at gcc dot gnu.org
@ 2023-11-12 22:13 ` pinskia at gcc dot gnu.org
2023-11-13 9:57 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-12 22:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
But we should also be rejecting:
```
struct A {
__attribute__((__vector_size__(4))) int d : 1;
};
struct A b = {0};
```
Which we currently accepts before and ICE now.
Note for the float case, we could in theory change:
```
/* Detect invalid bit-field type. */
if (TREE_CODE (*type) != INTEGER_TYPE
&& TREE_CODE (*type) != BOOLEAN_TYPE
&& TREE_CODE (*type) != ENUMERAL_TYPE
&& TREE_CODE (*type) != BITINT_TYPE)
{
error_at (loc, "bit-field %qs has invalid type", name);
*type = unsigned_type_node;
}
```
to use error_mark_node instead of unsigned_type_node here and that would fix
the ICE for the original testcase but not the above testcase.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111811] [14 Regression] ICE with vector float bitfield after error
2023-10-14 17:09 [Bug c/111811] New: gcc: internal compiler error: tree check: expected none of vector_type, have vector_type in finish_struct congli at smail dot nju.edu.cn
2023-11-12 22:09 ` [Bug c/111811] [14 Regression] ICE with vector float bitfield after error pinskia at gcc dot gnu.org
2023-11-12 22:13 ` pinskia at gcc dot gnu.org
@ 2023-11-13 9:57 ` rguenth at gcc dot gnu.org
2023-11-13 23:24 ` joseph at codesourcery dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-13 9:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jsm28 at gcc dot gnu.org
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I agree, this shouldn't be a valid bit-field type. We apply the vector_size
attribute before parsing/applying :1. There must be code to reject
float : 1, not sure where that is.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111811] [14 Regression] ICE with vector float bitfield after error
2023-10-14 17:09 [Bug c/111811] New: gcc: internal compiler error: tree check: expected none of vector_type, have vector_type in finish_struct congli at smail dot nju.edu.cn
` (2 preceding siblings ...)
2023-11-13 9:57 ` rguenth at gcc dot gnu.org
@ 2023-11-13 23:24 ` joseph at codesourcery dot com
2023-11-14 8:07 ` rguenther at suse dot de
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: joseph at codesourcery dot com @ 2023-11-13 23:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
The checks are in check_bitfield_type_and_width. I expect the attribute -
in this position a declaration attribute - gets applied after that (and
while applying it results in a change to the type, and thus in the
declaration being laid out again, this check doesn't get repeated).
In this case, the existing check is correct but not sufficient. In
another case the check is arguably too early:
struct s { int __attribute__ ((__mode__ (DI))) x : 50; };
Considering int __attribute__ ((__mode__ (DI))) as a DImode integer type,
that bit-field width is valid - but it's rejected because the check is
carried out on int, before the attribute gets applied. Getting that case
to work might require extracting early those declaration attributes that
actually affect the type, so they can be applied to the type before the
declaration gets constructed and such checks are carried out.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111811] [14 Regression] ICE with vector float bitfield after error
2023-10-14 17:09 [Bug c/111811] New: gcc: internal compiler error: tree check: expected none of vector_type, have vector_type in finish_struct congli at smail dot nju.edu.cn
` (3 preceding siblings ...)
2023-11-13 23:24 ` joseph at codesourcery dot com
@ 2023-11-14 8:07 ` rguenther at suse dot de
2024-01-15 13:54 ` rguenth at gcc dot gnu.org
2024-05-07 7:42 ` [Bug c/111811] [14/15 " rguenth at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: rguenther at suse dot de @ 2023-11-14 8:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> ---
On Mon, 13 Nov 2023, joseph at codesourcery dot com wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
>
> --- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
> The checks are in check_bitfield_type_and_width. I expect the attribute -
> in this position a declaration attribute - gets applied after that (and
> while applying it results in a change to the type, and thus in the
> declaration being laid out again, this check doesn't get repeated).
>
> In this case, the existing check is correct but not sufficient. In
> another case the check is arguably too early:
>
> struct s { int __attribute__ ((__mode__ (DI))) x : 50; };
>
> Considering int __attribute__ ((__mode__ (DI))) as a DImode integer type,
> that bit-field width is valid - but it's rejected because the check is
> carried out on int, before the attribute gets applied. Getting that case
> to work might require extracting early those declaration attributes that
> actually affect the type, so they can be applied to the type before the
> declaration gets constructed and such checks are carried out.
Ah, and when applying the vector_size attribute the FIELD_DECL hasn't been
updated to indicate we identified it as bitfield (so we could reject
the attribute) ...
I'll leave this to frontend folks to sort out.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111811] [14 Regression] ICE with vector float bitfield after error
2023-10-14 17:09 [Bug c/111811] New: gcc: internal compiler error: tree check: expected none of vector_type, have vector_type in finish_struct congli at smail dot nju.edu.cn
` (4 preceding siblings ...)
2023-11-14 8:07 ` rguenther at suse dot de
@ 2024-01-15 13:54 ` rguenth at gcc dot gnu.org
2024-05-07 7:42 ` [Bug c/111811] [14/15 " rguenth at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-15 13:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c/111811] [14/15 Regression] ICE with vector float bitfield after error
2023-10-14 17:09 [Bug c/111811] New: gcc: internal compiler error: tree check: expected none of vector_type, have vector_type in finish_struct congli at smail dot nju.edu.cn
` (5 preceding siblings ...)
2024-01-15 13:54 ` rguenth at gcc dot gnu.org
@ 2024-05-07 7:42 ` rguenth at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07 7:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111811
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|14.0 |14.2
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-05-07 7:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-14 17:09 [Bug c/111811] New: gcc: internal compiler error: tree check: expected none of vector_type, have vector_type in finish_struct congli at smail dot nju.edu.cn
2023-11-12 22:09 ` [Bug c/111811] [14 Regression] ICE with vector float bitfield after error pinskia at gcc dot gnu.org
2023-11-12 22:13 ` pinskia at gcc dot gnu.org
2023-11-13 9:57 ` rguenth at gcc dot gnu.org
2023-11-13 23:24 ` joseph at codesourcery dot com
2023-11-14 8:07 ` rguenther at suse dot de
2024-01-15 13:54 ` rguenth at gcc dot gnu.org
2024-05-07 7:42 ` [Bug c/111811] [14/15 " 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).