public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
@ 2020-05-08 14:20 okannen at gmail dot com
2021-07-31 20:19 ` [Bug c++/95009] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: okannen at gmail dot com @ 2020-05-08 14:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
Bug ID: 95009
Summary: decltype of increment or decrement bitfield
expressions are wrong and causes assembler errors.
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: okannen at gmail dot com
Target Milestone: ---
This bug exists since gcc version 6
The code bellow should not compile:
#include <type_traits>
struct A
{
int i:31;
};
A a;
//I am not sure the standard require that (a.i) and ++a.i have the same type.
static_assert(!std::is_same_v <decltype ((a.i)), decltype(++a.i)>);
// int& int:31&
//but I do believe that decltype(a.i+=1) and decltype(++a.i) shall have the
same type
static_assert(!std::is_same_v <decltype ((a.i+=1)), decltype(++a.i)>);
// int& int:31&
[expr.pre.incr]/1 "The expression ++x is equivalent to x+=1."
Actualy those weird "int:N" types cause a lot of trouble. This code cause
assembler error:
//test.cpp
struct A{
int i:31;
};
template <class T>
void f(){
}
int main(){
A a;
f<decltype(a.i+=1)>();
f<decltype(++a.i)>();
return 0;
}
`c++ test.cpp` outputs:
/tmp/ccTayNZZ.s: Assembler messages:
/tmp/ccTayNZZ.s:43: Error: symbol `_Z1fIRiEvv' is already defined
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95009] [9/10/11/12 Regression] decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
@ 2021-07-31 20:19 ` pinskia at gcc dot gnu.org
2021-07-31 20:21 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-31 20:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |assemble-failure,
| |ice-checking,
| |ice-on-valid-code
Target Milestone|--- |9.5
Known to fail| |12.0, 4.8.1
Known to work| |4.7.1
Last reconfirmed| |2021-07-31
Summary|decltype of increment or |[9/10/11/12 Regression]
|decrement bitfield |decltype of increment or
|expressions are wrong and |decrement bitfield
|causes assembler errors. |expressions are wrong and
| |causes assembler errors.
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95009] [9/10/11/12 Regression] decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
2021-07-31 20:19 ` [Bug c++/95009] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
@ 2021-07-31 20:21 ` pinskia at gcc dot gnu.org
2021-12-03 8:23 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-31 20:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There is most likely a missing unlowered_expr_type somewhere in the decltype
handling.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95009] [9/10/11/12 Regression] decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
2021-07-31 20:19 ` [Bug c++/95009] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2021-07-31 20:21 ` pinskia at gcc dot gnu.org
@ 2021-12-03 8:23 ` pinskia at gcc dot gnu.org
2021-12-03 8:25 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=70733,
| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=84516
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There is most likely a missing call to unlowered_expr_type somewhere, most
likely in finish_unary_op_expr.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95009] [9/10/11/12 Regression] decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
` (2 preceding siblings ...)
2021-12-03 8:23 ` pinskia at gcc dot gnu.org
@ 2021-12-03 8:25 ` pinskia at gcc dot gnu.org
2021-12-04 16:12 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-03 8:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |84516, 70733
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
PR 84516 and PR 70733 are about other unary operations too (+ and -).
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70733
[Bug 70733] Wrong code with nested structs and bit field.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84516
[Bug 84516] bitfield temporaries > 32-bits have wrong type
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95009] [9/10/11/12 Regression] decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
` (3 preceding siblings ...)
2021-12-03 8:25 ` pinskia at gcc dot gnu.org
@ 2021-12-04 16:12 ` mpolacek at gcc dot gnu.org
2021-12-07 13:26 ` 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-12-04 16:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
CC| |mpolacek at gcc dot gnu.org
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95009] [9/10/11/12 Regression] decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
` (4 preceding siblings ...)
2021-12-04 16:12 ` mpolacek at gcc dot gnu.org
@ 2021-12-07 13:26 ` cvs-commit at gcc dot gnu.org
2021-12-07 13:53 ` [Bug c++/95009] [9/10/11 " 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-12-07 13:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:3a2257e6b3fa288d6c50831987949b9ff7dfb865
commit r12-5823-g3a2257e6b3fa288d6c50831987949b9ff7dfb865
Author: Marek Polacek <polacek@redhat.com>
Date: Sat Dec 4 12:07:41 2021 -0500
c++: Fix for decltype and bit-fields [PR95009]
Here, decltype deduces the wrong type for certain expressions involving
bit-fields. Unlike in C, in C++ bit-field width is explicitly not part
of the type, so I think decltype should never deduce to 'int:N'. The
problem isn't that we're not calling unlowered_expr_type--we are--it's
that is_bitfield_expr_with_lowered_type only handles certain codes, but
not others. For example, += works fine but ++ does not.
This also fixes decltype-bitfield2.C where we were crashing (!), but
unfortunately it does not fix 84516 or 70733 where the problem is likely
a missing call to unlowered_expr_type. It occurs to me now that typeof
likely has had the same issue, but this patch should fix that too.
PR c++/95009
gcc/cp/ChangeLog:
* typeck.c (is_bitfield_expr_with_lowered_type) <case MODIFY_EXPR>:
Handle UNARY_PLUS_EXPR, NEGATE_EXPR, NON_LVALUE_EXPR, BIT_NOT_EXPR,
P*CREMENT_EXPR too.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/decltype-bitfield1.C: New test.
* g++.dg/cpp0x/decltype-bitfield2.C: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95009] [9/10/11 Regression] decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
` (5 preceding siblings ...)
2021-12-07 13:26 ` cvs-commit at gcc dot gnu.org
@ 2021-12-07 13:53 ` mpolacek at gcc dot gnu.org
2021-12-07 14:30 ` cvs-commit at gcc dot gnu.org
2021-12-07 14:31 ` [Bug c++/95009] [9/10 " mpolacek at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-12-07 13:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[9/10/11/12 Regression] |[9/10/11 Regression]
|decltype of increment or |decltype of increment or
|decrement bitfield |decrement bitfield
|expressions are wrong and |expressions are wrong and
|causes assembler errors. |causes assembler errors.
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far, will backport to gcc 11.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95009] [9/10/11 Regression] decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
` (6 preceding siblings ...)
2021-12-07 13:53 ` [Bug c++/95009] [9/10/11 " mpolacek at gcc dot gnu.org
@ 2021-12-07 14:30 ` cvs-commit at gcc dot gnu.org
2021-12-07 14:31 ` [Bug c++/95009] [9/10 " mpolacek at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-12-07 14:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:e3fab19a79e3dc3cdf3e54ca20107e1dc15a3927
commit r11-9363-ge3fab19a79e3dc3cdf3e54ca20107e1dc15a3927
Author: Marek Polacek <polacek@redhat.com>
Date: Sat Dec 4 12:07:41 2021 -0500
c++: Fix for decltype and bit-fields [PR95009]
Here, decltype deduces the wrong type for certain expressions involving
bit-fields. Unlike in C, in C++ bit-field width is explicitly not part
of the type, so I think decltype should never deduce to 'int:N'. The
problem isn't that we're not calling unlowered_expr_type--we are--it's
that is_bitfield_expr_with_lowered_type only handles certain codes, but
not others. For example, += works fine but ++ does not.
This also fixes decltype-bitfield2.C where we were crashing (!), but
unfortunately it does not fix 84516 or 70733 where the problem is likely
a missing call to unlowered_expr_type. It occurs to me now that typeof
likely has had the same issue, but this patch should fix that too.
PR c++/95009
gcc/cp/ChangeLog:
* typeck.c (is_bitfield_expr_with_lowered_type) <case MODIFY_EXPR>:
Handle UNARY_PLUS_EXPR, NEGATE_EXPR, NON_LVALUE_EXPR, BIT_NOT_EXPR,
P*CREMENT_EXPR too.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/decltype-bitfield1.C: New test.
* g++.dg/cpp0x/decltype-bitfield2.C: New test.
(cherry picked from commit 3a2257e6b3fa288d6c50831987949b9ff7dfb865)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/95009] [9/10 Regression] decltype of increment or decrement bitfield expressions are wrong and causes assembler errors.
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
` (7 preceding siblings ...)
2021-12-07 14:30 ` cvs-commit at gcc dot gnu.org
@ 2021-12-07 14:31 ` mpolacek at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-12-07 14:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95009
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[9/10/11 Regression] |[9/10 Regression] decltype
|decltype of increment or |of increment or decrement
|decrement bitfield |bitfield expressions are
|expressions are wrong and |wrong and causes assembler
|causes assembler errors. |errors.
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed for GCC 11+.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-12-07 14:31 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08 14:20 [Bug c++/95009] New: decltype of increment or decrement bitfield expressions are wrong and causes assembler errors okannen at gmail dot com
2021-07-31 20:19 ` [Bug c++/95009] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2021-07-31 20:21 ` pinskia at gcc dot gnu.org
2021-12-03 8:23 ` pinskia at gcc dot gnu.org
2021-12-03 8:25 ` pinskia at gcc dot gnu.org
2021-12-04 16:12 ` mpolacek at gcc dot gnu.org
2021-12-07 13:26 ` cvs-commit at gcc dot gnu.org
2021-12-07 13:53 ` [Bug c++/95009] [9/10/11 " mpolacek at gcc dot gnu.org
2021-12-07 14:30 ` cvs-commit at gcc dot gnu.org
2021-12-07 14:31 ` [Bug c++/95009] [9/10 " 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).