[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2024-04-12 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

--- Comment #10 from Patrick Palka  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:df7bfdb7dbf2d46aa5768a0280d4dcfcc868b7f9

commit r14-9947-df7bfdb7dbf2d46aa5768a0280d4dcfcc868b7f9
Author: Jason Merrill 
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(static_cast(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 

[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2024-04-12 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

--- Comment #9 from Patrick Palka  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:d435571b54b02946c97b5b24f20e5a7058fd96a1

commit r14-9946-gd435571b54b02946c97b5b24f20e5a7058fd96a1
Author: Jason Merrill 
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 

[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2024-03-21 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

Andrew Pinski  changed:

   What|Removed |Added

 CC||cvoica at gmail dot com

--- Comment #8 from Andrew Pinski  ---
*** Bug 114410 has been marked as a duplicate of this bug. ***

[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2024-03-14 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

--- Comment #7 from Andrew Pinski  ---
Note I noticed the testcase in PR 90390 ICEs starting in GCC 13 and it seems
similar to the testcase in comment #0 here.

[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2024-03-12 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org
   Priority|P1  |P2

--- Comment #6 from Jakub Jelinek  ---
GCC 13.{1,2} has been released with this bug, so P2.

[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2024-03-07 Thread law at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

Jeffrey A. Law  changed:

   What|Removed |Added

   Priority|P3  |P1
 CC||law at gcc dot gnu.org

[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2024-01-24 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

Patrick Palka  changed:

   What|Removed |Added

   Keywords||ice-on-valid-code

--- Comment #5 from Patrick Palka  ---
(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;
}

[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2024-01-23 Thread slyfox at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

Sergei Trofimovich  changed:

   What|Removed |Added

 CC||slyfox at gcc dot gnu.org

--- Comment #4 from Sergei Trofimovich  ---
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;
| ^

[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2024-01-02 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

Patrick Palka  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  ---
(In reply to Andrew Pinski from comment #2)
> Confirmed.
> 
> 
> I suspect this will bisect to r13-1755-g68f37670eff0b872 .
Yes, thus mine..

[Bug c++/113141] [13/14 Regression] ICE on conversion to reference in aggregate initialization

2023-12-25 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113141

Andrew Pinski  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  ---
Confirmed.


I suspect this will bisect to r13-1755-g68f37670eff0b872 .