[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 --- Comment #7 from Jakub Jelinek --- Author: jakub Date: Wed Apr 25 07:10:16 2018 New Revision: 259629 URL: https://gcc.gnu.org/viewcvs?rev=259629=gcc=rev Log: PR c++/85437 PR c++/49171 * cp-tree.h (REINTERPRET_CAST_P): New. * constexpr.c (cxx_eval_constant_expression) : Reject REINTERPET_CAST_P conversions. Use cplus_expand_constant for non-trivial PTRMEM_CST cases. * typeck.c (build_nop_reinterpret): New. (build_reinterpret_cast_1): Use it. Set REINTERPRET_CAST_P on NOP_EXPRs returned by cp_convert. * g++.dg/cpp0x/addressof1.C: Make reinterpret cases runtime checks. * g++.dg/cpp0x/constexpr-cast.C: Remove xfails * g++.dg/cpp0x/constexpr-nullptr-2.C: Likewise. * g++.dg/cpp0x/constexpr-pmf1.C: Check when optimized. * g++.dg/cpp0x/pr85437-1.C: New. * g++.dg/cpp0x/pr85437-2.C: New. * g++.dg/cpp0x/pr85437-3.C: New. * g++.dg/cpp0x/pr85437-4.C: New. Added: trunk/gcc/testsuite/g++.dg/cpp0x/pr85437-1.C trunk/gcc/testsuite/g++.dg/cpp0x/pr85437-2.C trunk/gcc/testsuite/g++.dg/cpp0x/pr85437-3.C trunk/gcc/testsuite/g++.dg/cpp0x/pr85437-4.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/constexpr.c trunk/gcc/cp/cp-tree.h trunk/gcc/cp/typeck.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/cpp0x/addressof1.C trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-cast.C trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr-2.C trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-pmf1.C
[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 Jakub Jelinek changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #8 from Jakub Jelinek --- Fixed by Nathan.
[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 Nathan Sidwell changed: What|Removed |Added Status|NEW |ASSIGNED
[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 Richard Biener changed: What|Removed |Added Priority|P3 |P1 Known to work||7.3.1
[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 Alexandre Oliva changed: What|Removed |Added CC||aoliva at gcc dot gnu.org --- Comment #6 from Alexandre Oliva --- FTR, there's a patch with various caveats at https://gcc.gnu.org/ml/gcc-patches/2018-04/msg00852.html
[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 Jakub Jelinek changed: What|Removed |Added CC||jason at gcc dot gnu.org Target Milestone|--- |8.0 --- Comment #5 from Jakub Jelinek --- (gdb) p debug_tree (type) unit-size align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffefc625e8 precision:32 min max pointer_to_this > DI size constant 64> unit-size constant 8> align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffefd9d150 basetype > $4 = void (gdb) p debug_tree (op->typed.type) unit-size align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffefc625e8 precision:32 min max pointer_to_this > DI size constant 64> unit-size constant 8> align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fffefd9d3f0 basetype > Ah, one has basetype A, the other B, and both: 4600if (same_type_ignoring_top_level_qualifiers_p (type, 4601 TREE_TYPE (op)) 4602|| can_convert_qual (type, op)) tests fail in this case.
[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 --- Comment #4 from Jakub Jelinek --- convert_ptrmem here creates a NOP_EXPR around the PTRMEM_CST, even when it is for a static cast rather than reinterpret_cast. The OFFSET_TYPEs are different, but they have the same TREE_TYPE etc. Then constexpr.c doesn't consider that cast to be usable in constant expressions and because it is called with allow_non_constant, it wraps the new PTRMEM_CST with another NOP_EXPR and that is where following constexpr.c call errors on.
[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- *** Bug 85438 has been marked as a duplicate of this bug. ***
[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 Marek Polacek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2018-04-17 CC||mpolacek at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Marek Polacek --- Confirmed.
[Bug c++/85437] [8 Regression] member pointer static upcast rejected in a constexpr context
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85437 Martin Sebor changed: What|Removed |Added Keywords||rejects-valid --- Comment #1 from Martin Sebor --- The first revision to reject the test case is r249088: Overhaul pointer-to-member conversion and template argument handling. * call.c (standard_conversion): Avoid creating ck_pmem when the class type is the same. * cvt.c (can_convert_qual): Split from perform_qualification_conversions. * constexpr.c (cxx_eval_constant_expression): Check it. * typeck.c (convert_ptrmem): Only cplus_expand_constant if adjustment is necessary. * pt.c (check_valid_ptrmem_cst_expr): Compare class types. (convert_nontype_argument): Avoid redundant error.