[Bug c++/105996] [10/11/12/13 Regression] reinterpret_cast in constexpr failure creating a pair with a function pointer of class parent

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jun 16 15:36:40 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105996

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem is that build_ptrmemfunc in
9587          if (TREE_CODE (pfn) != PTRMEM_CST)
9588            {
9589              if (same_type_p (to_type, pfn_type))
9590                return pfn;
9591              else if (integer_zerop (n) && TREE_CODE (pfn) != CONSTRUCTOR)
9592                return build_reinterpret_cast (input_location, to_type,
pfn, 
9593                                               complain);
9594            }
calls build_reintepret_cast from void (A::*)() typed pfn to void (B::*)() type,
and when we then constant expression evaluate it, we reject it because
reinterpret_cast is not a core constant expression as per
https://eel.is/c++draft/expr.const#5.16
Now, is this reinterpret cast just some implementation detail under the hood in
which we should somehow arrange for REINTERPRET_CAST_P bit not be set (or
afterwards remove it)?


More information about the Gcc-bugs mailing list