public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization
@ 2023-12-26 1:36 de34 at live dot cn
2023-12-26 5:12 ` [Bug c++/113141] " pinskia at gcc dot gnu.org
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: de34 at live dot cn @ 2023-12-26 1:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Bug ID: 113141
Summary: ICE on conversion to reference in aggregate
initialization
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Keywords: ice-checking, ice-on-invalid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: de34 at live dot cn
Target Milestone: ---
The following program triggers ICE since GCC 13
(https://godbolt.org/z/PaqWsG9s6):
```
int global_x{};
struct ConvToRef {
operator int&() { return global_x; }
};
struct Foo { int& r; };
int main()
{
Foo bar{ { ConvToRef{} } };
}
```
Clang considers this ill-formed and emits "non-const lvalue reference to type
'int' cannot bind to an initializer list temporary".
If the type of r is changed to const int&, the program correctly compiles with
GCC.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
@ 2023-12-26 5:12 ` pinskia at gcc dot gnu.org
2023-12-26 5:14 ` [Bug c++/113141] [13/14 Regression] " pinskia at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-26 5:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |accelerator0099 at gmail dot com
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 113142 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
2023-12-26 5:12 ` [Bug c++/113141] " pinskia at gcc dot gnu.org
@ 2023-12-26 5:14 ` pinskia at gcc dot gnu.org
2024-01-02 18:25 ` ppalka at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-26 5:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=105766,
| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=106201,
| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=94894
Target Milestone|--- |13.3
Keywords|ice-checking |
Last reconfirmed| |2023-12-26
Status|UNCONFIRMED |NEW
Summary|ICE on conversion to |[13/14 Regression] ICE on
|reference in aggregate |conversion to reference in
|initialization |aggregate initialization
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
I suspect this will bisect to r13-1755-g68f37670eff0b872 .
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
2023-12-26 5:12 ` [Bug c++/113141] " pinskia at gcc dot gnu.org
2023-12-26 5:14 ` [Bug c++/113141] [13/14 Regression] " pinskia at gcc dot gnu.org
@ 2024-01-02 18:25 ` ppalka at gcc dot gnu.org
2024-01-24 7:48 ` slyfox at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-01-02 18:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|NEW |ASSIGNED
CC| |ppalka at gcc dot gnu.org
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> Confirmed.
>
>
> I suspect this will bisect to r13-1755-g68f37670eff0b872 .
Yes, thus mine..
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (2 preceding siblings ...)
2024-01-02 18:25 ` ppalka at gcc dot gnu.org
@ 2024-01-24 7:48 ` slyfox at gcc dot gnu.org
2024-01-24 15:47 ` ppalka at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: slyfox at gcc dot gnu.org @ 2024-01-24 7:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Sergei Trofimovich <slyfox at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |slyfox at gcc dot gnu.org
--- Comment #4 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Noticed a similar ICE in openmvs-2.2.0 against gcc-13/gcc-14. I reduced it with
cvise into something invalid:
$ cat SceneDensify.cpp.cpp
class Matrix struct TPoint3 {
typedef Matrix EVec;
operator const EVec();
void Init() {
TPoint3 X;
(EVec &)X;
}
};
$ g++ -c SceneDensify.cpp.cpp -o bug.o
SceneDensify.cpp.cpp: In member function 'void TPoint3::Init()':
SceneDensify.cpp.cpp:6:13: internal compiler error: in reference_binding, at
cp/call.cc:2020
6 | (EVec &)X;
| ^
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (3 preceding siblings ...)
2024-01-24 7:48 ` slyfox at gcc dot gnu.org
@ 2024-01-24 15:47 ` ppalka at gcc dot gnu.org
2024-03-07 20:53 ` law at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-01-24 15:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Sergei Trofimovich from comment #4)
> Noticed a similar ICE in openmvs-2.2.0 against gcc-13/gcc-14. I reduced it
> with cvise into something invalid:
Interesting, this can be turned into a ice-on-valid testcase:
struct Matrix { };
struct TPoint3 { operator const Matrix(); };
int main() {
TPoint3 X;
Matrix& m = (Matrix &)X;
}
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (4 preceding siblings ...)
2024-01-24 15:47 ` ppalka at gcc dot gnu.org
@ 2024-03-07 20:53 ` law at gcc dot gnu.org
2024-03-12 13:21 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-07 20:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Jeffrey A. Law <law at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
CC| |law at gcc dot gnu.org
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (5 preceding siblings ...)
2024-03-07 20:53 ` law at gcc dot gnu.org
@ 2024-03-12 13:21 ` jakub at gcc dot gnu.org
2024-03-14 18:27 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-03-12 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Priority|P1 |P2
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 13.{1,2} has been released with this bug, so P2.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (6 preceding siblings ...)
2024-03-12 13:21 ` jakub at gcc dot gnu.org
@ 2024-03-14 18:27 ` pinskia at gcc dot gnu.org
2024-03-21 9:07 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-14 18:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note I noticed the testcase in PR 90390 ICEs starting in GCC 13 and it seems
similar to the testcase in comment #0 here.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (7 preceding siblings ...)
2024-03-14 18:27 ` pinskia at gcc dot gnu.org
@ 2024-03-21 9:07 ` pinskia at gcc dot gnu.org
2024-04-12 20:14 ` ppalka at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-21 9:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |cvoica at gmail dot com
--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 114410 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (8 preceding siblings ...)
2024-03-21 9:07 ` pinskia at gcc dot gnu.org
@ 2024-04-12 20:14 ` ppalka at gcc dot gnu.org
2024-04-12 20:15 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-12 20:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:d435571b54b02946c97b5b24f20e5a7058fd96a1
commit r14-9946-gd435571b54b02946c97b5b24f20e5a7058fd96a1
Author: Jason Merrill <jason@redhat.com>
Date: Fri Apr 12 13:24:44 2024 -0400
c++: reference list-init, conversion fn [PR113141]
The original testcase in PR113141 is an instance of CWG1996; the standard
fails to consider conversion functions when initializing a reference
directly from an initializer-list of one element, but then does consider
them when initializing a temporary. I have a proposed fix for this defect,
which is implemented here.
DR 1996
PR c++/113141
gcc/cp/ChangeLog:
* call.cc (reference_binding): Check direct binding from
a single-element list.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-ref1.C: New test.
* g++.dg/cpp0x/initlist-ref2.C: New test.
* g++.dg/cpp0x/initlist-ref3.C: New test.
Co-authored-by: Patrick Palka <ppalka@redhat.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (9 preceding siblings ...)
2024-04-12 20:14 ` ppalka at gcc dot gnu.org
@ 2024-04-12 20:15 ` ppalka at gcc dot gnu.org
2024-05-01 22:16 ` [Bug c++/113141] [13 " cvs-commit at gcc dot gnu.org
2024-05-01 22:19 ` ppalka at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-04-12 20:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
--- Comment #10 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:df7bfdb7dbf2d46aa5768a0280d4dcfcc868b7f9
commit r14-9947-df7bfdb7dbf2d46aa5768a0280d4dcfcc868b7f9
Author: Jason Merrill <jason@redhat.com>
Date: Wed Apr 10 15:12:26 2024 -0400
c++: reference cast, conversion fn [PR113141]
The second testcase in 113141 is a separate issue: we first decide that the
conversion is ill-formed, but then when recalculating the special c_cast_p
handling makes us think it's OK. We don't want that, it should continue to
fall back to the reinterpret_cast interpretation. And while we're here,
let's warn that we're not using the conversion function.
Note that the standard seems to say that in this case we should
treat (Matrix &) as const_cast<Matrix &>(static_cast<const Matrix &>(X)),
which would use the conversion operator, but that doesn't match existing
practice, so let's resolve that another day. I've raised this issue with
CWG; at the moment I lean toward never binding a temporary in a C-style
cast
to reference type, which would also be a change from existing practice.
PR c++/113141
gcc/c-family/ChangeLog:
* c.opt: Add -Wcast-user-defined.
gcc/ChangeLog:
* doc/invoke.texi: Document -Wcast-user-defined.
gcc/cp/ChangeLog:
* call.cc (reference_binding): For an invalid cast, warn and don't
recalculate.
gcc/testsuite/ChangeLog:
* g++.dg/conversion/ref12.C: New test.
Co-authored-by: Patrick Palka <ppalka@redhat.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (10 preceding siblings ...)
2024-04-12 20:15 ` ppalka at gcc dot gnu.org
@ 2024-05-01 22:16 ` cvs-commit at gcc dot gnu.org
2024-05-01 22:19 ` ppalka at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-01 22:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:
https://gcc.gnu.org/g:c70abea054fe0021b7b2c2e07996afaadc17a07b
commit r13-8670-gc70abea054fe0021b7b2c2e07996afaadc17a07b
Author: Patrick Palka <ppalka@redhat.com>
Date: Wed May 1 18:16:08 2024 -0400
c++: problematic assert in reference_binding [PR113141]
r14-9946 / r14-9947 fixed this PR properly for GCC 14.
For GCC 13, let's just remove the problematic assert.
PR c++/113141
gcc/cp/ChangeLog:
* call.cc (reference_binding): Remove badness criteria sanity
check in the recursive case.
gcc/testsuite/ChangeLog:
* g++.dg/conversion/ref12.C: New test.
* g++.dg/cpp0x/initlist-ref1.C: new test.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/113141] [13 Regression] ICE on conversion to reference in aggregate initialization
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
` (11 preceding siblings ...)
2024-05-01 22:16 ` [Bug c++/113141] [13 " cvs-commit at gcc dot gnu.org
@ 2024-05-01 22:19 ` ppalka at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-05-01 22:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #12 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for 13.3/14.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2024-05-01 22:19 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-26 1:36 [Bug c++/113141] New: ICE on conversion to reference in aggregate initialization de34 at live dot cn
2023-12-26 5:12 ` [Bug c++/113141] " pinskia at gcc dot gnu.org
2023-12-26 5:14 ` [Bug c++/113141] [13/14 Regression] " pinskia at gcc dot gnu.org
2024-01-02 18:25 ` ppalka at gcc dot gnu.org
2024-01-24 7:48 ` slyfox at gcc dot gnu.org
2024-01-24 15:47 ` ppalka at gcc dot gnu.org
2024-03-07 20:53 ` law at gcc dot gnu.org
2024-03-12 13:21 ` jakub at gcc dot gnu.org
2024-03-14 18:27 ` pinskia at gcc dot gnu.org
2024-03-21 9:07 ` pinskia at gcc dot gnu.org
2024-04-12 20:14 ` ppalka at gcc dot gnu.org
2024-04-12 20:15 ` ppalka at gcc dot gnu.org
2024-05-01 22:16 ` [Bug c++/113141] [13 " cvs-commit at gcc dot gnu.org
2024-05-01 22:19 ` ppalka 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).